From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615563820; cv=none; d=zohomail.com; s=zohoarc; b=Alk/sulI5/BmfRBAZ3Ny7hMFh0Gu/Jl+7lp4zn6yqLtafr/nArwxPP5OTX1GL2zCQ2KovhBW6qbU2yf394Jjn6vORjqgtzpFtYOgFTbBtUHJmrVBPlUJC05KUHJZxgi3WCNEMdQU0fUBkjzpVwHrX31rgEchw80zUDOnU89nog4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615563820; 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=yPFBI6Ls0cDy5c5Ba2DEzMLC/LQxs/TE9x0y8BI0IUs=; b=A5raOJQFIMalOxpeB0EeKXs8NfBfzOYWXo+4M7x5Yppm7GVemrPDlrXu54JYZ11sLscIcXgzU664RRuDrDPFKZ3Y7+kd28AN5yLeT4e4iDnyG25HjPGK6gzHCpuzKIb471FCd6RUWubgn6daRLQpqQLc9QnFXJeC+b3o2Xi/0Rs= 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 1615563820088512.9940671484338; Fri, 12 Mar 2021 07:43:40 -0800 (PST) Received: from localhost ([::1]:34232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKjww-000829-T8 for importer@patchew.org; Fri, 12 Mar 2021 10:43:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-0001dU-RS for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjlw-00024t-Eb for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:20 -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-284-2rh_hh6MM-GuGL2oZ7If5A-1; Fri, 12 Mar 2021 10:32: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 2767C1966325; Fri, 12 Mar 2021 15:32:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B888F1001281; Fri, 12 Mar 2021 15:32:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 41C551132C13; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563135; 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=yPFBI6Ls0cDy5c5Ba2DEzMLC/LQxs/TE9x0y8BI0IUs=; b=cDxBQtadBfk7cnOl8n2iVwHFtxXXREqzqIoW4SiWH/dbqaxFCg2dhSpMF++I1Ryo6Pu1Aw tNpUDOcedfwI9KRKMzy+RS5p3ZBWkzy07KfybHUdf8aF0yeLoEMzVm0WRMpVQ6JBvf0lqO b7qUHybkLxU9cnEvFRYNSB1dX8yqQOE= X-MC-Unique: 2rh_hh6MM-GuGL2oZ7If5A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 01/10] qemu-options: New -compat to set policy for deprecated interfaces Date: Fri, 12 Mar 2021 16:32:01 +0100 Message-Id: <20210312153210.2810514-2-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" New option -compat lets you configure what to do when deprecated interfaces get used. This is intended for testing users of the management interfaces. It is experimental. -compat deprecated-input=3D configures what to do when deprecated input is received. Input policy can be "accept" (accept silently), or "reject" (reject the request with an error). -compat deprecated-output=3D configures what to do when deprecated output is sent. 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. Note that there is no good way for management application to detect presence of -compat: it's not visible output of query-qmp-schema or query-command-line-options. Tolerable, because it's meant for testing. If running with -compat fails, skip the test. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- 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/meson.build | 1 + qemu-options.hx | 20 ++++++++++++++ 7 files changed, 113 insertions(+) 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..d2c02a21aa --- /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.2 +## +{ 'enum': 'CompatPolicyInput', + 'data': [ 'accept', 'reject' ] } + +## +# @CompatPolicyOutput: +# +# Policy for handling "funny" output. +# +# @accept: Pass on unchanged +# @hide: Filter out +# +# Since: 5.2 +## +{ '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.2 +## +{ 'struct': 'CompatPolicy', + 'data': { '*deprecated-input': 'CompatPolicyInput', + '*deprecated-output': 'CompatPolicyOutput' } } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 3441c9a9ae..4912b9744e 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -79,6 +79,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..b8c6638156 --- /dev/null +++ b/include/qapi/compat-policy.h @@ -0,0 +1,20 @@ +/* + * Policy for handling "funny" management interfaces + * + * Copyright (C) 2020 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 0a2b20a4e4..45090f881a 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" =20 #include "block/aio.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" @@ -23,6 +24,8 @@ #include "qemu/coroutine.h" #include "qemu/main-loop.h" =20 +CompatPolicy compat_policy; + static QDict *qmp_dispatch_check_obj(QDict *dict, bool allow_oob, Error **errp) { diff --git a/softmmu/vl.c b/softmmu/vl.c index b7673b9613..4c53b2940c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -29,6 +29,7 @@ #include "exec/cpu-common.h" #include "hw/boards.h" #include "hw/qdev-properties.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qemu-version.h" @@ -113,6 +114,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-migration.h" @@ -3413,6 +3415,21 @@ void qemu_init(int argc, char **argv, char **envp) enable_mlock =3D 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/meson.build b/qapi/meson.build index fcb15a78f1..376f4ceafe 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -24,6 +24,7 @@ qapi_all_modules =3D [ 'block-export', 'char', 'common', + 'compat', 'control', 'crypto', 'dump', diff --git a/qemu-options.hx b/qemu-options.hx index 90801286c6..2be2feed32 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3470,6 +3470,26 @@ DEFHEADING() =20 DEFHEADING(Debug/Expert options:) =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) +SRST +``-compat [deprecated-input=3D@var{input-policy}][,deprecated-output=3D@va= r{output-policy}]`` + Set policy for handling deprecated management interfaces (experimental= ): + + ``deprecated-input=3Daccept`` (default) + Accept deprecated commands and arguments + ``deprecated-input=3Dreject`` + Reject deprecated commands and arguments + ``deprecated-output=3Daccept`` (default) + Emit deprecated command results and events + ``deprecated-output=3Dhide`` + Suppress deprecated command results and events + + Limitation: covers only syntactic aspects of QMP. +ERST + 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.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615564953; cv=none; d=zohomail.com; s=zohoarc; b=bLL9BLFr30us+SBdTUhL4JJvMbLGM5HNLEdZEVTaU9AiHBPWH8Z4mKs0Sq6kLNp3SW8pEOePyqeJJyJNxj0reMxh+mwTpgKWYkHmG9EE/3Fr80yT/Pd9zZSw8cnLk+jlYxToBYKZVYEarJ2yf6IM7aFeW1jCCXJzEZ0dlXDVBik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615564953; 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=ZpN3P2WeVFMeYjDoe3XELQUKtBNCZFfp0EOjMPHUzlU=; b=cY0DMO52DPosK6jY1Zg912DXQXy9IwPMgzekR5ppFjhnequQit6kHNqgnzn0g3E9vrRF1fbck4HA1zh+mkFDzzxRvfxb6qAyIvOTIBJI23bJKFRZOfDGTCJi7FaIxnP9CAT9l4jFCr8IcNhRvPev09Rd2I2O5sNf2b3dCct6x18= 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 1615564953881507.2097666219712; Fri, 12 Mar 2021 08:02:33 -0800 (PST) Received: from localhost ([::1]:43456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKkFD-0006wK-0y for importer@patchew.org; Fri, 12 Mar 2021 11:02:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm6-0001jc-8Z for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjlx-00025Y-MV for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:25 -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-286-jsOOdDScNOCbwoI6au293A-1; Fri, 12 Mar 2021 10:32:13 -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 4857F83DD28; Fri, 12 Mar 2021 15:32:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B67D95C1D5; Fri, 12 Mar 2021 15:32:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4591A1132C14; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563135; 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=ZpN3P2WeVFMeYjDoe3XELQUKtBNCZFfp0EOjMPHUzlU=; b=O4bmvKO8smO8ptwaI0rPkHLjY90Gj3Xo89Wx5HN51GnvUWqbnOjSkUDNQTTKyNHmXTNHtL hd65VerSgb3mRMhfWlK6rJTPjAAAiQWUM+qCSv33BQ4HJlDzISQ+f1ADQgs2uHf7WTki4f BGIfgjHNNzxtCTCPbHvCaYX+lyl428s= X-MC-Unique: jsOOdDScNOCbwoI6au293A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 02/10] qapi: Implement deprecated-output=hide for QMP command results Date: Fri, 12 Mar 2021 16:32:02 +0100 Message-Id: <20210312153210.2810514-3-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP command results. Example: when QEMU is run with -compat deprecated-output=3Dhide, then {"execute": "query-cpus-fast"} yields {"return": [{"thread-id": 9805, "props": {"core-id": 0, "thread-id": 0,= "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-index":= 0, "target": "x86_64"}]} instead of {"return": [{"arch": "x86", "thread-id": 22436, "props": {"core-id": 0,= "thread-id": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0= ]", "cpu-index": 0, "target": "x86_64"}]} Note the suppression of deprecated member "arch". Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- 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 ++++++++++++++++++++++--- qapi/trace-events | 1 + scripts/qapi/commands.py | 2 +- scripts/qapi/visit.py | 12 +++++++ tests/qapi-schema/qapi-schema-test.json | 17 +++++----- tests/qapi-schema/qapi-schema-test.out | 18 +++++------ 11 files changed, 118 insertions(+), 23 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 7362c043be..2d853255a3 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -113,6 +113,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 ebc19ede7f..4d23b59853 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -459,6 +459,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 7e5f40e7f0..d9726ecaa1 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -135,6 +135,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 ba6f6ac8a7..5c4aa0f64d 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 */ @@ -207,6 +210,13 @@ static bool qobject_output_type_null(Visitor *v, const= char *name, return true; } =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. */ @@ -256,6 +266,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 @@ -264,3 +275,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 d3413bfef0..1079d35122 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" @@ -49,12 +50,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_new0(FeatureStruct1, 1); } =20 void qmp_test_command_features1(Error **errp) @@ -275,6 +281,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) { @@ -349,6 +379,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/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 0a75a9371b..7adeda917b 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -96,7 +96,7 @@ def gen_marshal_output(ret_type: QAPISchemaType) -> str: { Visitor *v; =20 - v =3D qobject_output_visitor_new(ret_out); + v =3D qobject_output_visitor_new_qmp(ret_out); if (visit_type_%(c_name)s(v, "unused", &ret_in, errp)) { visit_complete(v, ret_out); } diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 9aa0b1e11e..9d83bf650f 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -77,6 +77,7 @@ def gen_visit_object_members(name: str, 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(''' @@ -84,6 +85,12 @@ def gen_visit_object_members(name: str, ''', name=3Dmemb.name, c_name=3Dc_name(memb.name)) indent.increase() + if deprecated: + ret +=3D mcgen(''' + if (visit_deprecated(v, "%(name)s")) { +''', + name=3Dmemb.name) + indent.increase() ret +=3D mcgen(''' if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) { return false; @@ -91,6 +98,11 @@ def gen_visit_object_members(name: str, ''', c_type=3Dmemb.type.c_name(), name=3Dmemb.name, c_name=3Dc_name(memb.name)) + if deprecated: + indent.decrease() + ret +=3D mcgen(''' + } +''') if memb.optional: indent.decrease() ret +=3D mcgen(''' diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 63f92adf68..48a0adabae 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -299,14 +299,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 3b1387d9f1..776d737891 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -409,15 +409,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.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615563896; cv=none; d=zohomail.com; s=zohoarc; b=axhkBsu1WiWF6IX3E8tpomQUwW540FSgP/J4YVR5lsNdjyuxG8JE11cZ5EQGx6KVWNKMlQI35tmgfUhSSrRITJAmbnzhKOt060QVu4ZoLVraz2qmF3iiK1ABUrfEEmoq9d4CBW/vplLgLV0eeC/Ei+xh9025Qh00hTH3awwTiLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615563896; 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=FcPR1hJ2xtBF5Bp+6Tg1ASrwfVbZDssm45eW+qG7Tpw=; b=eT2Zukkqcpap/a7Tqp2TT5dnsifioJX50E+IpNNG70p7cGGUZPWsYuckIrnAlm1ztdePwU6zkW0Is2xF/ETZXLzriydANBiBYhy41DUwjmBzOifS6ybEJD2upCSbBbOaC9F3niOloVz+FfA8UXknzS3M3+cJ35+/5fPmt0SAfpU= 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 1615563896949230.90994177988227; Fri, 12 Mar 2021 07:44:56 -0800 (PST) Received: from localhost ([::1]:36100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKjyA-0000Oh-U1 for importer@patchew.org; Fri, 12 Mar 2021 10:44:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm4-0001gG-R3 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjly-00025w-GS for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:24 -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-523-65jVckklOgWEb2RxNcZwIg-1; Fri, 12 Mar 2021 10:32:13 -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 08382108BD0D; Fri, 12 Mar 2021 15:32:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6F5259443; Fri, 12 Mar 2021 15:32:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 491021131C01; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563137; 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=FcPR1hJ2xtBF5Bp+6Tg1ASrwfVbZDssm45eW+qG7Tpw=; b=gLsWJyvY1jxTW0hvfNpA5THf8whYYh1WITr+h+/JHxLhGWSlE30h4DN2nojSQSwcaC9yVJ zkHs+KRQUWE6GkAY+6oBw41nMV0Doari236zPFSW6miY5aPJGmiXwnSf6Shc+P4f2+ob6w AEcjd+R6NVc5YYKRyW+i0RWrfdQ9u9o= X-MC-Unique: 65jVckklOgWEb2RxNcZwIg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 03/10] qapi: Implement deprecated-output=hide for QMP events Date: Fri, 12 Mar 2021 16:32:03 +0100 Message-Id: <20210312153210.2810514-4-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP events: suppress deprecated ones. No QMP event is deprecated right now. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-qmp-event.c | 20 ++++++++++++++++++++ scripts/qapi/events.py | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 7dd0053190..ab059fb5c2 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,24 @@ 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.has_deprecated_output =3D true; + 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 +167,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/scripts/qapi/events.py b/scripts/qapi/events.py index 90d2f6156d..f6e1e76f64 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -79,6 +79,7 @@ def gen_param_var(typ: QAPISchemaObjectType) -> str: =20 def gen_event_send(name: str, arg_type: Optional[QAPISchemaObjectType], + features: List[QAPISchemaFeature], boxed: bool, event_enum_name: str, event_emit: str) -> str: @@ -107,6 +108,14 @@ def gen_event_send(name: str, 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"); @@ -176,6 +185,7 @@ def _begin_user_module(self, name: str) -> None: #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" @@ -220,7 +230,7 @@ def visit_event(self, boxed: bool) -> None: 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 --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615563731; cv=none; d=zohomail.com; s=zohoarc; b=IPw3ylIgOxVuwIZp8BP/CYlezZmUhSVEuqK2GOC+wKQAlScXc7IEzow4tV0Ahj+Hj4XgariYk/pL8/7ltqYscNu4inuwWy026caK2avHDrTF4kLre+Kqjlep+70hw7QtazCTs/cM9etvqIOAk3kIKg8SwMsxoGs80Y5kaP+XDR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615563731; 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=OlN3ddArZGWKmSDSzb0Tab2OHF57vCqvoEbVLu8/hAw=; b=JXFkbwKmZ4B0E1A8gGagKfEl3p9rEQ4vYBaDEyZs6nHWxyyZsdyHT4Y6MeFzND371b/dC8sqHfjtmIkZH6bRvOqlS3uCSNSdieuOs/AVPtTRGk1sEBtdJ/6K9jXzSVAf2TTM+ZoKwEMRyMdkVS4CAY5aT3i2NPO2+PeDMSv/ToY= 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 16155637314721011.4335096685096; Fri, 12 Mar 2021 07:42:11 -0800 (PST) Received: from localhost ([::1]:57496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKjvW-00056l-C6 for importer@patchew.org; Fri, 12 Mar 2021 10:42:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm5-0001hN-A4 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-000264-A4 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:24 -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-592-MntSKC_BNMGHKAZiWy7YRA-1; Fri, 12 Mar 2021 10:32:16 -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 833F4100C618; Fri, 12 Mar 2021 15:32:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B774F19744; Fri, 12 Mar 2021 15:32:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4C4EF1141CBD; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563138; 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=OlN3ddArZGWKmSDSzb0Tab2OHF57vCqvoEbVLu8/hAw=; b=WivOmWf58pICWInuVrwv9jhY1Oscjd+s0xFM0rDfxMRSuC4fUV1wijhl0CMcVnJ9hXTBI8 p07kgYi/Vk9wI5RmEDGJ9AGWQjcBn7JC10eL+/2KAU8kq/mJbGOWmOenxDg77xH4qc1ZNP mSNaUVq2gUqDIXNe3YeKlKQUj1qVfJU= X-MC-Unique: MntSKC_BNMGHKAZiWy7YRA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 04/10] qapi: Implement deprecated-output=hide for QMP event data Date: Fri, 12 Mar 2021 16:32:04 +0100 Message-Id: <20210312153210.2810514-5-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP event data: suppress deprecated members. No QMP event data is deprecated right now. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-qmp-event.c | 21 +++++++++++++++++++++ scripts/qapi/events.py | 8 ++++++-- tests/qapi-schema/qapi-schema-test.json | 3 +++ tests/qapi-schema/qapi-schema-test.out | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index ab059fb5c2..047f44ff9a 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -159,6 +159,26 @@ static void test_event_deprecated(TestEventData *data,= const void *unused) qobject_unref(data->expect); } =20 +static void test_event_deprecated_data(TestEventData *data, const void *un= used) +{ + memset(&compat_policy, 0, sizeof(compat_policy)); + + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES0'," + " 'data': { 'foo': 42 } }"); + qapi_event_send_test_event_features0(42); + g_assert(data->emitted); + + qobject_unref(data->expect); + + compat_policy.has_deprecated_output =3D true; + compat_policy.deprecated_output =3D COMPAT_POLICY_OUTPUT_HIDE; + data->expect =3D qdict_from_jsonf_nofail("{ 'event': 'TEST-EVENT-FEATU= RES0' }"); + qapi_event_send_test_event_features0(42); + g_assert(data->emitted); + + qobject_unref(data->expect); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -168,6 +188,7 @@ int main(int argc, char **argv) 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); + event_test_add("/event/deprecated_data", test_event_deprecated_data); g_test_run(); =20 return 0; diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index f6e1e76f64..8335c2bdfc 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -126,7 +126,7 @@ def gen_event_send(name: str, if have_args: assert arg_type is not None ret +=3D mcgen(''' - v =3D qobject_output_visitor_new(&obj); + v =3D qobject_output_visitor_new_qmp(&obj); ''') if not arg_type.is_implicit(): ret +=3D mcgen(''' @@ -145,7 +145,11 @@ def gen_event_send(name: str, ret +=3D mcgen(''' =20 visit_complete(v, &obj); - qdict_put_obj(qmp, "data", obj); + if (qdict_size(qobject_to(QDict, obj))) { + qdict_put_obj(qmp, "data", obj); + } else { + qobject_unref(obj); + } ''') =20 ret +=3D mcgen(''' diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 48a0adabae..12ec588b52 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -324,5 +324,8 @@ 'features': [ { 'name': 'feature1', 'if': [ 'defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)'] }= ] } =20 +{ 'event': 'TEST-EVENT-FEATURES0', + 'data': 'FeatureStruct1' } + { 'event': 'TEST-EVENT-FEATURES1', 'features': [ 'deprecated' ] } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 776d737891..f5741df97f 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -440,6 +440,8 @@ 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-FEATURES0 FeatureStruct1 + boxed=3DFalse event TEST-EVENT-FEATURES1 None boxed=3DFalse feature deprecated --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615564142; cv=none; d=zohomail.com; s=zohoarc; b=bd0WIZJw9eC6jcdW/vJg9Y49KnF1HiZ0Mdx9rLjtMmIJ6L8NJJqCRIqG6+MOrnmhoMlzvEIfwEB05pSNl718bXG69D5QfI+GSmVB6ER6ElUujKG6tPh75dIsgiHDy51xOwBRRwWhh+LYLmxg5q5IPpoX6y9x1HuXNHPHv6UJSZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615564142; 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=MH7N7oxLYyR90VvSf/orXfkA9JOOHoLOvMQDQOQcNu4=; b=dgrZHvM4+Qf9knbmlX1/y54uCqAhlPtq+lvIkWR0goNwhiStN3eI7lBaOgry1b0+Hrt9dhkWis1K/FMbueXDv9Z9+xpyxEjPMJWPK541tqpJhF+J3TMm3MOW/dbTY2r5lyTMiqgCufAsm2+jyX+fq2nZy4VbF+l8pgFWLsV/gdI= 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 1615564142715523.2538317850374; Fri, 12 Mar 2021 07:49:02 -0800 (PST) Received: from localhost ([::1]:44014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKk29-00072A-IP for importer@patchew.org; Fri, 12 Mar 2021 10:49:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm6-0001kK-Ik for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-00026I-Aa for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:26 -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-389-wP2Frm6MO6msehaaYVGm1Q-1; Fri, 12 Mar 2021 10:32:15 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7D2F107ACCD; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 815CE610A8; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4F9E2114200B; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563139; 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=MH7N7oxLYyR90VvSf/orXfkA9JOOHoLOvMQDQOQcNu4=; b=C3UB+Heqxbbnp+0jIYq49jKlB3qUGzbcikiIC2oW7v/mEFrnPPUIHYAIXgNI7A3eK6AEpr Gwx0N9rmEAxfucZ0TCGL42pK4Db5kMJXF5UCvvSskK0oFt34jBA+Ac2PxiwZKT3wNa+CMT 7ciI0mVw4xx+tJXihZDH024w8LT+VMc= X-MC-Unique: wP2Frm6MO6msehaaYVGm1Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 05/10] monitor: Drop query-qmp-schema 'gen': false hack Date: Fri, 12 Mar 2021 16:32:05 +0100 Message-Id: <20210312153210.2810514-6-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" QMP commands return their response as a generated QAPI type, which the monitor core converts to JSON via QObject. query-qmp-schema's response is the generated introspection data. This is a QLitObject since commit 7d0f982bfb "qapi: generate a literal qobject for introspection", v2.12). Before, it was a string. Instead of converting QLitObject / string -> QObject -> QAPI type SchemaInfoList -> QObject -> JSON, we take a shortcut: the command is 'gen': false, so it can return the QObject instead of the QAPI type. Slightly simpler and more efficient. The next commit will filter the response for output policy, and this is easier in the SchemaInfoList representation. Drop the shortcut. This replaces the manual command registration by a generated one. The manual registration makes the commnd available before the machine is built by passing flag QCO_ALLOW_PRECONFIG. To keep it available there, we need need to add 'allow-preconfig': true to its definition in the schema. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qapi/introspect.json | 2 +- monitor/monitor-internal.h | 3 --- monitor/misc.c | 2 -- monitor/qmp-cmds-control.c | 29 ++++++++++++++++------------ storage-daemon/qemu-storage-daemon.c | 2 -- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/qapi/introspect.json b/qapi/introspect.json index 944bb87a20..39bd303778 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -49,7 +49,7 @@ ## { 'command': 'query-qmp-schema', 'returns': [ 'SchemaInfo' ], - 'gen': false } # just to simplify qmp_query_json() + 'allow-preconfig': true } =20 ## # @SchemaMetaType: diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 40903d6386..9c3a09cb01 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -183,7 +183,4 @@ void help_cmd(Monitor *mon, const char *name); void handle_hmp_command(MonitorHMP *mon, const char *cmdline); int hmp_compare_cmd(const char *name, const char *list); =20 -void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, - Error **errp); - #endif diff --git a/monitor/misc.c b/monitor/misc.c index a7650ed747..0b46006e42 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -231,8 +231,6 @@ static void monitor_init_qmp_commands(void) =20 qmp_init_marshal(&qmp_commands); =20 - qmp_register_command(&qmp_commands, "query-qmp-schema", - qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG); qmp_register_command(&qmp_commands, "device_add", qmp_device_add, QCO_NO_OPTIONS); qmp_register_command(&qmp_commands, "object-add", qmp_object_add, diff --git a/monitor/qmp-cmds-control.c b/monitor/qmp-cmds-control.c index 509ae870bd..25afd0867f 100644 --- a/monitor/qmp-cmds-control.c +++ b/monitor/qmp-cmds-control.c @@ -26,10 +26,14 @@ =20 #include "monitor-internal.h" #include "qemu-version.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qapi-commands-control.h" +#include "qapi/qapi-commands-introspect.h" #include "qapi/qapi-emit-events.h" #include "qapi/qapi-introspect.h" +#include "qapi/qapi-visit-introspect.h" +#include "qapi/qobject-input-visitor.h" =20 /* * Accept QMP capabilities in @list for @mon. @@ -154,17 +158,18 @@ EventInfoList *qmp_query_events(Error **errp) return ev_list; } =20 -/* - * Minor hack: generated marshalling suppressed for this command - * ('gen': false in the schema) so we can parse the JSON string - * directly into QObject instead of first parsing it with - * visit_type_SchemaInfoList() into a SchemaInfoList, then marshal it - * to QObject with generated output marshallers, every time. Instead, - * we do it in test-qobject-input-visitor.c, just to make sure - * qapi-gen.py's output actually conforms to the schema. - */ -void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, - Error **errp) +SchemaInfoList *qmp_query_qmp_schema(Error **errp) { - *ret_data =3D qobject_from_qlit(&qmp_schema_qlit); + QObject *obj =3D qobject_from_qlit(&qmp_schema_qlit); + Visitor *v =3D qobject_input_visitor_new(obj); + SchemaInfoList *schema =3D NULL; + + /* test_visitor_in_qmp_introspect() ensures this can't fail */ + visit_type_SchemaInfoList(v, NULL, &schema, &error_abort); + g_assert(schema); + + qobject_unref(obj); + visit_free(v); + + return schema; } diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 23756fc8e5..02afdbeafc 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -146,8 +146,6 @@ static QemuOptsList qemu_object_opts =3D { static void init_qmp_commands(void) { qmp_init_marshal(&qmp_commands); - qmp_register_command(&qmp_commands, "query-qmp-schema", - qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG); qmp_register_command(&qmp_commands, "object-add", qmp_object_add, QCO_NO_OPTIONS); =20 --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615564371; cv=none; d=zohomail.com; s=zohoarc; b=ZDQzWksOazzZ+VuM3Ky+L6H50jdyBFJgEDLvtdHF0mAVmE7p6uUMdaU8/gbmtpWsliUJJNikv4ZsmdDv6nF/QShPU2RygOiOI3qVTSuTLgvY2SI0kSKfDRiO+OOwYuGThRmSbZZr2rW9H2rcpo/q3gMBZEs5BgUSwC2ouKeWGjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615564371; 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=JiBAY8Ph8pCMCkLPiTkLWgfEcm4xATm5/gqCF2fhqjM=; b=h88QJnpXb/26mDUftyJ+5YSyrfMPQiXeHZgoGHWSuiaAkSZHsV6g3S3sU83BM9tOrjaze0U9dJcZuT24LN6YaXCrjnnSbIE89VnAFHLim48iQPmlmq0/0wHMu+JZk/f5Gwe4GZpKynkgAToADaOqG/ioodZfe/ztyzq49CW1oNE= 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 1615564371822414.0952119388148; Fri, 12 Mar 2021 07:52:51 -0800 (PST) Received: from localhost ([::1]:50650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKk5q-0001wr-Gq for importer@patchew.org; Fri, 12 Mar 2021 10:52:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm9-0001pW-27 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-00026A-AG for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:28 -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-522-TExDeZRXMbmvjxNJn3wE0A-1; Fri, 12 Mar 2021 10:32:14 -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 B703A800D55; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 823E460636; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 52D5B114423C; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563138; 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=JiBAY8Ph8pCMCkLPiTkLWgfEcm4xATm5/gqCF2fhqjM=; b=i2wNnZ8kbxHOGTVtGDeoqYp5voOKQHlSVL2VGDRV+3cs6NYjh9dwmppW+k/2GuaHOottAd 429p62as4ewTFq5yJNYcT/nL7wE6/8IPd0/PjFsHU0yMD6d7sAlQYXpLiT7zUPU+Ai89jH WZw2OGMp7QlxIS/TX3YOMxCl1FTULNg= X-MC-Unique: TExDeZRXMbmvjxNJn3wE0A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 06/10] qapi: Implement deprecated-output=hide for QMP introspection Date: Fri, 12 Mar 2021 16:32:06 +0100 Message-Id: <20210312153210.2810514-7-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP command query-qmp-schema: suppress information on deprecated commands, events and object type members, i.e. anything that has the special feature flag "deprecated". Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- monitor/qmp-cmds-control.c | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/monitor/qmp-cmds-control.c b/monitor/qmp-cmds-control.c index 25afd0867f..bcfccc4ac4 100644 --- a/monitor/qmp-cmds-control.c +++ b/monitor/qmp-cmds-control.c @@ -158,6 +158,74 @@ EventInfoList *qmp_query_events(Error **errp) return ev_list; } =20 +static void *split_off_generic_list(void *list, + bool (*splitp)(void *elt), + void **part) +{ + GenericList *keep =3D NULL, **keep_tailp =3D &keep; + GenericList *split =3D NULL, **split_tailp =3D &split; + GenericList *tail; + + for (tail =3D list; tail; tail =3D tail->next) { + if (splitp(tail)) { + *split_tailp =3D tail; + split_tailp =3D &tail->next; + } else { + *keep_tailp =3D tail; + keep_tailp =3D &tail->next; + } + } + + *keep_tailp =3D *split_tailp =3D NULL; + *part =3D split; + return keep; +} + +static bool is_in(const char *s, strList *list) +{ + strList *tail; + + for (tail =3D list; tail; tail =3D tail->next) { + if (!strcmp(tail->value, s)) { + return true; + } + } + return false; +} + +static bool is_entity_deprecated(void *link) +{ + return is_in("deprecated", ((SchemaInfoList *)link)->value->features); +} + +static bool is_member_deprecated(void *link) +{ + return is_in("deprecated", + ((SchemaInfoObjectMemberList *)link)->value->features); +} + +static SchemaInfoList *zap_deprecated(SchemaInfoList *schema) +{ + void *to_zap; + SchemaInfoList *tail; + SchemaInfo *ent; + + schema =3D split_off_generic_list(schema, is_entity_deprecated, &to_za= p); + qapi_free_SchemaInfoList(to_zap); + + for (tail =3D schema; tail; tail =3D tail->next) { + ent =3D tail->value; + if (ent->meta_type =3D=3D SCHEMA_META_TYPE_OBJECT) { + ent->u.object.members + =3D split_off_generic_list(ent->u.object.members, + is_member_deprecated, &to_zap); + qapi_free_SchemaInfoObjectMemberList(to_zap); + } + } + + return schema; +} + SchemaInfoList *qmp_query_qmp_schema(Error **errp) { QObject *obj =3D qobject_from_qlit(&qmp_schema_qlit); @@ -171,5 +239,8 @@ SchemaInfoList *qmp_query_qmp_schema(Error **errp) qobject_unref(obj); visit_free(v); =20 + if (compat_policy.deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) { + return zap_deprecated(schema); + } return schema; } --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615565359; cv=none; d=zohomail.com; s=zohoarc; b=XD9/orJgF9iMjtqJ3DKLN1WakYAHEKsHkgkJwm4DvEPg8lULbIazgdWA5w1ktd2jq7WJ3gpXCqhzOUlqFmoT846AdvZZWNeukhp4FxNS9K8rv7MfFcLfA8ZSi1woYaMizvnr6LCE4PE6U2SJTFi6R91dKROLlvJqYRBv58/SmKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615565359; 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=NVJuMAPYdH7w1cPqRknSuCjIVEZVFL1qFF7T/zXDyQA=; b=Ss6kQyTqDsCd/cxnjIq92KNDzB/ss6rHL2K4f1QpxzBj2m5u6XgPO3NTXl5rQU1x+P+maRLnsYcoQZamp2TGuzD/S5O7IZ5mXxSzQIuBjBLOgFIlRQpdGRUOy2CAJAK/sC4HI20VeFrxtyueq0tSsxunlX43GXVP5Ji4H70LqaA= 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 1615565359496880.9952471533181; Fri, 12 Mar 2021 08:09:19 -0800 (PST) Received: from localhost ([::1]:57098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKkLm-0001AS-7M for importer@patchew.org; Fri, 12 Mar 2021 11:09:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm7-0001mz-Ri for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-00026E-Ab for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:27 -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-512-zWA6hN2UOP-KPnm4k_OXag-1; Fri, 12 Mar 2021 10:32:15 -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 0199E801817; Fri, 12 Mar 2021 15:32:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 811295C1D5; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 564071126898; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563138; 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=NVJuMAPYdH7w1cPqRknSuCjIVEZVFL1qFF7T/zXDyQA=; b=X01sGWMymIU3mRcdIIt2etn10yfDfCxhAcjo5JF70IBfL31erXMIc4m8TY0tvsAbriFvUF xHpkWH6HYwQKlsrPcAuFqDKgDFoNQm9P1rB0HRxIwOZGWXRe6qoO73lKf3GnmBWldd0IlB K6MdEAS4MXsU/yhg6vMH4fbKIgGp7MY= X-MC-Unique: zWA6hN2UOP-KPnm4k_OXag-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 07/10] test-util-sockets: Add stub for monitor_set_cur() Date: Fri, 12 Mar 2021 16:32:07 +0100 Message-Id: <20210312153210.2810514-8-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , marcandre.lureau@gmail.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" Without this stub, the next commit fails to link. I suspect the real cause is 947e47448d "monitor: Use getter/setter functions for cur_mon". Cc: Kevin Wolf Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-util-sockets.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 67486055ed..72b9246529 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -73,6 +73,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Erro= r **errp) * otherwise we get duplicate syms at link time. */ Monitor *monitor_cur(void) { return cur_mon; } +Monitor *monitor_set_cur(Coroutine *co, Monitor *mon) { abort(); } int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); } =20 #ifndef _WIN32 --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615564706; cv=none; d=zohomail.com; s=zohoarc; b=Tcy3aWH2V0af4WY9PMb+hCFOro+fJgG0T+0ITjFOyhZeNKMGcJcCfiYZr9R+2CI8HpTOtbxVYi7e2zwRdijsO3ZSu0crVAJ8mwuVh0K8P5ZkcYteXul0lGl2KO1Y7hfuqZMNs7LN5llr4bqOd+SY7QBhnn55oKK9yhcvmnctauQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615564706; 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=vsOWI/zLF88vHDt6hNjmwuvxV0xDLzDnuxhmObsfL5k=; b=mvLkuV+0jMFDQGWjY4O/IIfJWAJn6PlQyz8kRXCUgz9JVI1rq7aZ8PLwvi/Ekz6ut4f/g9ikAiVNUFTQEYzFdjQkPsYJ1UWZeK4kjcGLzbDNBVwKF5/Go3+MxRzcARtXtWUGSNNiW0Kgpp6b5SErqXJSPqMthn5C6yyp/tJkvSM= 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 1615564706213476.5390597018952; Fri, 12 Mar 2021 07:58:26 -0800 (PST) Received: from localhost ([::1]:34918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKkBF-0001Yp-4g for importer@patchew.org; Fri, 12 Mar 2021 10:58:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm5-0001ge-0u for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56361) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjly-00025o-Gh for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:24 -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-597-iOU6qFjaODq_U8oGKLI9iA-1; Fri, 12 Mar 2021 10:32:15 -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 D93F48015BD; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81DD95D75F; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 598D31126899; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563136; 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=vsOWI/zLF88vHDt6hNjmwuvxV0xDLzDnuxhmObsfL5k=; b=gChNqSh7wrXE/NO88+x1pi3E96GaaBHTj2zedyNsGJW+k4FbnvPWgwL10thfgS7Ij8vOdn B7H2SbaHHfVcl+XjKCIDJtysvpqNZ0MK+FGwCXRkQrrQ78Q0Rz61uvYRrSk40POD4y8kwk 8jx9MnKN1OgBjJhvImsrMEF4kFIbnFg= X-MC-Unique: iOU6qFjaODq_U8oGKLI9iA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 08/10] qapi: Implement deprecated-input=reject for QMP commands Date: Fri, 12 Mar 2021 16:32:08 +0100 Message-Id: <20210312153210.2810514-9-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy rejects deprecated input, and thus permits "testing the future". Implement it for QMP commands: make deprecated ones fail. Example: when QEMU is run with -compat deprecated-input=3Dreject, then {"execute": "query-cpus"} fails like this {"error": {"class": "CommandNotFound", "desc": "Deprecated command quer= y-cpus disabled by policy"}} When the deprecated command is removed, the error will change to {"error": {"class": "CommandNotFound", "desc": "The command query-cpus = has not been found"}} Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/qmp/dispatch.h | 1 + qapi/qmp-dispatch.c | 13 +++++++++++++ tests/test-qmp-cmds.c | 24 ++++++++++++++++++++++++ scripts/qapi/commands.py | 10 +++++++--- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 1486cac3ef..8b974b570e 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -26,6 +26,7 @@ typedef enum QmpCommandOptions QCO_ALLOW_OOB =3D (1U << 1), QCO_ALLOW_PRECONFIG =3D (1U << 2), QCO_COROUTINE =3D (1U << 3), + QCO_DEPRECATED =3D (1U << 4), } QmpCommandOptions; =20 typedef struct QmpCommand diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 45090f881a..cbc4452341 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -158,6 +158,19 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObjec= t *request, "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/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 1079d35122..cba982154b 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -281,6 +281,28 @@ 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_ret_deprecated(void) { const char *cmd =3D "{ 'execute': 'test-features0' }"; @@ -379,6 +401,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_deprecated", + test_dispatch_cmd_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 7adeda917b..f5d97454af 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -210,12 +210,16 @@ def gen_marshal(name: str, =20 =20 def gen_register_command(name: str, + features: List[QAPISchemaFeature], success_response: bool, allow_oob: bool, allow_preconfig: bool, coroutine: bool) -> str: 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: @@ -326,9 +330,9 @@ def visit_command(self, self._genc.add(gen_marshal(name, arg_type, boxed, ret_type)) with self._temp_module('./init'): with ifcontext(ifcond, self._genh, self._genc): - self._genc.add(gen_register_command(name, success_response, - allow_oob, allow_preco= nfig, - coroutine)) + self._genc.add(gen_register_command( + name, features, success_response, allow_oob, + allow_preconfig, coroutine)) =20 =20 def gen_commands(schema: QAPISchema, --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615563690; cv=none; d=zohomail.com; s=zohoarc; b=M68SNtB0Hk/B88wq6/i6vcYuqAJysIu3ExImCj2zSw6fWw73YRruLOAnVyWemtJCOGOEUfoMaDN4uZwT5Z+9NlAByLAKoErXLc/hOJ23qg7GbjLLD4rE7Q+j4S6n3gBQiiGyHnZZOwrOlG3y6vBbrenVQoDejOf8ug0Ao2kQ9UE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615563690; 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=n6zUoRStw/Wf5FlusgUHiaUeDqHKLjQdmJ56NPXW3cI=; b=dyo87DUGsVnDs6Poiumlg15cNcBi1WGWuhfXouKst8I5nqumepohaV4CCI8hOTnzb1m+lyW4zcMN4fy6bEl3Up1/t6QG9FznPrzXguFRqrJ07w1DIdILpqXK76j5oaUTC4wpBiRHCqhqQLwFwcv0tV3maYKtgv0g1JN3Kg6KMGo= 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 1615563690562876.1802338081812; Fri, 12 Mar 2021 07:41:30 -0800 (PST) Received: from localhost ([::1]:55772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKjuq-000479-Vd for importer@patchew.org; Fri, 12 Mar 2021 10:41:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm2-0001f8-NX for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjly-00025r-G6 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:22 -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-389-J-X7bUWGMziftRXRUtPeCA-1; Fri, 12 Mar 2021 10:32:15 -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 DB7511966321; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 811FD5275D; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5CE9F112689A; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563137; 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=n6zUoRStw/Wf5FlusgUHiaUeDqHKLjQdmJ56NPXW3cI=; b=haOLI2yEdWcao4SgOKwd926ZZ6Xm2SBfqbUHtL4kHVAw5fCBp8IRU6EZ+wNIco1+7Tv4YM V49Ch+QB8W+XUwXuF7+yB4Gjr9Curfb5J+2l0RhLYTcGwZchfP4Jw0XSN6641gM/zkIdLu 5HU8+TY76vEGJey7CBD0cIq6xyzttcE= X-MC-Unique: J-X7bUWGMziftRXRUtPeCA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 09/10] qapi: Implement deprecated-input=reject for QMP command arguments Date: Fri, 12 Mar 2021 16:32:09 +0100 Message-Id: <20210312153210.2810514-10-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" This policy rejects deprecated input, and thus permits "testing the future". Implement it for QMP command arguments: reject commands with deprecated ones. Example: when QEMU is run with -compat deprecated-input=3Dreject, then {"execute": "eject", "arguments": {"device": "cd"}} fails like this {"error": {"class": "GenericError", "desc": "Deprecated parameter 'devi= ce' disabled by policy"}} When the deprecated parameter is removed, the error will change to {"error": {"class": "GenericError", "desc": "Parameter 'device' is unex= pected"}} Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/qobject-input-visitor.h | 9 +++++++++ include/qapi/visitor-impl.h | 3 +++ include/qapi/visitor.h | 9 +++++++++ qapi/qapi-visit-core.c | 9 +++++++++ qapi/qobject-input-visitor.c | 28 ++++++++++++++++++++++++++++ tests/test-qmp-cmds.c | 25 +++++++++++++++++++++++++ qapi/trace-events | 1 + scripts/qapi/commands.py | 2 +- scripts/qapi/visit.py | 3 +++ 9 files changed, 88 insertions(+), 1 deletion(-) 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 2d853255a3..3b950f6e3d 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -113,6 +113,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_accept)(Visitor *v, const char *name, Error **errp); + /* Optional */ bool (*deprecated)(Visitor *v, const char *name); =20 diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 4d23b59853..b3c9ef7a81 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -459,6 +459,15 @@ void visit_end_alternate(Visitor *v, void **obj); */ bool visit_optional(Visitor *v, const char *name, bool *present); =20 +/* + * Should we reject 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_accept(Visitor *v, const char *name, Error **errp); + /* * Should we visit deprecated member @name? * diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index d9726ecaa1..a641adec51 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -135,6 +135,15 @@ bool visit_optional(Visitor *v, const char *name, bool= *present) return *present; } =20 +bool visit_deprecated_accept(Visitor *v, const char *name, Error **errp) +{ + trace_visit_deprecated_accept(v, name); + if (v->deprecated_accept) { + return v->deprecated_accept(v, name, errp); + } + return true; +} + bool visit_deprecated(Visitor *v, const char *name) { trace_visit_deprecated(v, name); diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 23843b242e..1b8fa1f2f6 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; @@ -662,6 +664,23 @@ static void qobject_input_optional(Visitor *v, const c= har *name, bool *present) *present =3D true; } =20 +static bool qobject_input_deprecated_accept(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); @@ -696,6 +715,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_accept =3D qobject_input_deprecated_accept; v->visitor.free =3D qobject_input_free; =20 v->root =3D qobject_ref(obj); @@ -718,6 +738,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/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index cba982154b..266db074b4 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -303,6 +303,29 @@ static void test_dispatch_cmd_deprecated(void) do_qmp_dispatch_error(false, ERROR_CLASS_COMMAND_NOT_FOUND, cmd); } =20 +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' }"; @@ -403,6 +426,8 @@ int main(int argc, char **argv) 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/qapi/trace-events b/qapi/trace-events index eff1fbd199..3cabe912ae 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_accept(void *v, const char *name) "v=3D%p name=3D%s" 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" diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index f5d97454af..8ccd1d9224 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -154,7 +154,7 @@ def gen_marshal(name: str, =20 ret +=3D mcgen(''' =20 - v =3D qobject_input_visitor_new(QOBJECT(args)); + v =3D qobject_input_visitor_new_qmp(QOBJECT(args)); if (!visit_start_struct(v, NULL, NULL, 0, errp)) { goto out; } diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 9d83bf650f..9e96f3c566 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -87,6 +87,9 @@ def gen_visit_object_members(name: str, indent.increase() if deprecated: ret +=3D mcgen(''' + if (!visit_deprecated_accept(v, "%(name)s", errp)) { + return false; + } if (visit_deprecated(v, "%(name)s")) { ''', name=3Dmemb.name) --=20 2.26.2 From nobody Sat May 18 21:00:14 2024 Delivered-To: importer@patchew.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=1615565146; cv=none; d=zohomail.com; s=zohoarc; b=cHYCjzfXXLn8XgwXt1lAwqAwYW44qMlshkVfXa4yEi94rl4r69WNeqSa9LoL4WY4OT3bKbf1YoH/JrFj/odROVNCKrP8Kn+KZDJ1NWXA48hga217W3aVBxyAGHSoj8aQ4zgtvfjD0dOYfD5o8BfSTBwRyiSsonF0NDKd/ePDo4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615565146; 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=D9D3aB59k2menoLZdEd7UHxcbxrb4VJT2K6RGZ2RJno=; b=f6uxuhxdps9UXMZPtqFOCdo2/AJyPh2dTG55wZTK5O/84DEzID7jJWi5zVVfvlg/K65pdD6wzZRsCBvuxTl4GM2f5cwtz1gPVf/ij5SaDrKLhMmp5upfzFEAOLwXb6OXje6Q7BiFQtV2KMwvvcawe/JgBR6umE2LkX3YYe+YbKc= 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 1615565146552250.56714603113335; Fri, 12 Mar 2021 08:05:46 -0800 (PST) Received: from localhost ([::1]:50114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKkIL-0003so-AX for importer@patchew.org; Fri, 12 Mar 2021 11:05:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKjm7-0001mi-MO for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKjm0-00026D-AR for qemu-devel@nongnu.org; Fri, 12 Mar 2021 10:32:27 -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-512-xPEHy8UFPH6mhmbzHl4g2Q-1; Fri, 12 Mar 2021 10:32:15 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08AA183DD20; Fri, 12 Mar 2021 15:32:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-83.phx2.redhat.com [10.3.112.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCDDE610AE; Fri, 12 Mar 2021 15:32:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6027F11268A1; Fri, 12 Mar 2021 16:32:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615563138; 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=D9D3aB59k2menoLZdEd7UHxcbxrb4VJT2K6RGZ2RJno=; b=aqguhGVR51ghY0vMOEoCZT7McqYV3B8R9+AzuaE6XEX3qmpRcrDXniXoW6nrwQIx0kRz/M GZFdfQ2E8mARdUU7o1iXoTw7kFxP5q/XbZo3H7DZmWeSWfQWy6QOh0jVOsHS+1jcNnHbEm n85pH1641Gxj3/HDOjyvfFzc97yCcjI= X-MC-Unique: xPEHy8UFPH6mhmbzHl4g2Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v6 10/10] qapi: New -compat deprecated-input=crash Date: Fri, 12 Mar 2021 16:32:10 +0100 Message-Id: <20210312153210.2810514-11-armbru@redhat.com> In-Reply-To: <20210312153210.2810514-1-armbru@redhat.com> References: <20210312153210.2810514-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: marcandre.lureau@gmail.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" 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 Reviewed-by: Eric Blake --- qapi/compat.json | 9 +++++---- qapi/qmp-dispatch.c | 1 + qapi/qobject-input-visitor.c | 1 + qemu-options.hx | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/qapi/compat.json b/qapi/compat.json index d2c02a21aa..ae3afc22df 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.2 +# Since: 6.0 ## { 'enum': 'CompatPolicyInput', - 'data': [ 'accept', 'reject' ] } + 'data': [ 'accept', 'reject', 'crash' ] } =20 ## # @CompatPolicyOutput: @@ -25,7 +26,7 @@ # @accept: Pass on unchanged # @hide: Filter out # -# Since: 5.2 +# Since: 6.0 ## { 'enum': 'CompatPolicyOutput', 'data': [ 'accept', 'hide' ] } @@ -44,7 +45,7 @@ # @deprecated-input: how to handle deprecated input (default 'accept') # @deprecated-output: how to handle deprecated output (default 'accept') # -# Since: 5.2 +# Since: 6.0 ## { 'struct': 'CompatPolicy', 'data': { '*deprecated-input': 'CompatPolicyInput', diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index cbc4452341..12657d635e 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -167,6 +167,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject= *request, "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 1b8fa1f2f6..baad0dcd3c 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -676,6 +676,7 @@ static bool qobject_input_deprecated_accept(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 2be2feed32..165fa048e9 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3471,7 +3471,7 @@ DEFHEADING() DEFHEADING(Debug/Expert options:) =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) SRST @@ -3482,6 +3482,8 @@ SRST Accept deprecated commands and arguments ``deprecated-input=3Dreject`` Reject deprecated commands and arguments + ``deprecated-input=3Dcrash`` + Crash on deprecated commands and arguments ``deprecated-output=3Daccept`` (default) Emit deprecated command results and events ``deprecated-output=3Dhide`` --=20 2.26.2