From nobody Mon Feb 9 17:59:10 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635537483936678.0613022273103; Fri, 29 Oct 2021 12:58:03 -0700 (PDT) Received: from localhost ([::1]:45696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgY0o-0004t1-Um for importer@patchew.org; Fri, 29 Oct 2021 15:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgXaL-0000ko-Oc for qemu-devel@nongnu.org; Fri, 29 Oct 2021 15:30:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgXaF-0000wV-Pb for qemu-devel@nongnu.org; Fri, 29 Oct 2021 15:30:37 -0400 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-354-Wg2IegX-PEOWtNcKad9VZg-1; Fri, 29 Oct 2021 15:30:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE1DC8066F5; Fri, 29 Oct 2021 19:30:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FAF72B0B2; Fri, 29 Oct 2021 19:30:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 08D3811380DF; Fri, 29 Oct 2021 21:30:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635535834; 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=I4sGaYJsY+DMZiA2OVqIvCB4jvHs23/CgIKws8/0fJk=; b=ZVxL8ySQDsmo9SP78wKQeD6lpvVjKaqdxb6ttpbntw2W0ZDz9ikwNImDZhZckdm5bpdv6j FqJFpbJxVJVVmDQFR95+gHm+ms/FnSwaHadLJ7VGfTNqZ8qsobRkgEhP2hh3gMWGP6SkkA GKXkuKFpdcUxyng3y879eFDCt3YFAdQ= X-MC-Unique: Wg2IegX-PEOWtNcKad9VZg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 9/9] qapi: Extend -compat to set policy for unstable interfaces Date: Fri, 29 Oct 2021 21:30:15 +0200 Message-Id: <20211029193015.1312198-10-armbru@redhat.com> In-Reply-To: <20211029193015.1312198-1-armbru@redhat.com> References: <20211029193015.1312198-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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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: John Snow , richard.henderson@linaro.org, Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635537486064100001 Content-Type: text/plain; charset="utf-8" New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit 6dd75472d5 "qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental. For now, this covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'unstable'. We may want to extend it to cover semantic aspects, or the command line. Note that there is no good way for management application to detect presence of these new option parameters: they are 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 Acked-by: John Snow Message-Id: <20211028102520.747396-10-armbru@redhat.com> Reviewed-by: Eric Blake [Doc comments fixed up] --- qapi/compat.json | 8 +++++++- include/qapi/util.h | 1 + qapi/qapi-util.c | 6 ++++++ qapi/qobject-output-visitor.c | 8 ++++++-- qemu-options.hx | 20 +++++++++++++++++++- scripts/qapi/events.py | 10 ++++++---- scripts/qapi/schema.py | 10 ++++++---- 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/qapi/compat.json b/qapi/compat.json index 74a8493d3d..dd7261ae2a 100644 --- a/qapi/compat.json +++ b/qapi/compat.json @@ -47,9 +47,15 @@ # # @deprecated-input: how to handle deprecated input (default 'accept') # @deprecated-output: how to handle deprecated output (default 'accept') +# @unstable-input: how to handle unstable input (default 'accept') +# (since 6.2) +# @unstable-output: how to handle unstable output (default 'accept') +# (since 6.2) # # Since: 6.0 ## { 'struct': 'CompatPolicy', 'data': { '*deprecated-input': 'CompatPolicyInput', - '*deprecated-output': 'CompatPolicyOutput' } } + '*deprecated-output': 'CompatPolicyOutput', + '*unstable-input': 'CompatPolicyInput', + '*unstable-output': 'CompatPolicyOutput' } } diff --git a/include/qapi/util.h b/include/qapi/util.h index 0cc98db9f9..81a2b13a33 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -13,6 +13,7 @@ =20 typedef enum { QAPI_DEPRECATED, + QAPI_UNSTABLE, } QapiSpecialFeature; =20 typedef struct QEnumLookup { diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 53b493cb7e..fda7044539 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -49,6 +49,12 @@ bool compat_policy_input_ok(unsigned special_features, error_class, kind, name, errp)) { return false; } + if ((special_features & (1u << QAPI_UNSTABLE)) + && !compat_policy_input_ok1("Unstable", + policy->unstable_input, + error_class, kind, name, errp)) { + return false; + } return true; } =20 diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index b155bf4149..74770edd73 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -212,8 +212,12 @@ static bool qobject_output_type_null(Visitor *v, const= char *name, static bool qobject_output_policy_skip(Visitor *v, const char *name, unsigned special_features) { - return !(special_features & 1u << QAPI_DEPRECATED) - || v->compat_policy.deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_= HIDE; + CompatPolicy *pol =3D &v->compat_policy; + + return ((special_features & 1u << QAPI_DEPRECATED) + && pol->deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) + || ((special_features & 1u << QAPI_UNSTABLE) + && pol->unstable_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE); } =20 /* Finish building, and return the root object. diff --git a/qemu-options.hx b/qemu-options.hx index 5f375bbfa6..f051536b63 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3641,7 +3641,9 @@ DEFHEADING(Debug/Expert options:) =20 DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=3Daccept|reject|crash][,deprecated-output= =3Daccept|hide]\n" - " Policy for handling deprecated management interfaces\= n", + " Policy for handling deprecated management interfaces\= n" + "-compat [unstable-input=3Daccept|reject|crash][,unstable-output=3Dacc= ept|hide]\n" + " Policy for handling unstable management interfaces\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=3D@var{input-policy}][,deprecated-output=3D@va= r{output-policy}]`` @@ -3659,6 +3661,22 @@ SRST Suppress deprecated command results and events =20 Limitation: covers only syntactic aspects of QMP. + +``-compat [unstable-input=3D@var{input-policy}][,unstable-output=3D@var{ou= tput-policy}]`` + Set policy for handling unstable management interfaces (experimental): + + ``unstable-input=3Daccept`` (default) + Accept unstable commands and arguments + ``unstable-input=3Dreject`` + Reject unstable commands and arguments + ``unstable-input=3Dcrash`` + Crash on unstable commands and arguments + ``unstable-output=3Daccept`` (default) + Emit unstable command results and events + ``unstable-output=3Dhide`` + Suppress unstable command results and events + + Limitation: covers only syntactic aspects of QMP. ERST =20 DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg, diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 82475e84ec..27b44c49f5 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -109,13 +109,15 @@ 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(''' + for f in features: + if f.is_special(): + ret +=3D mcgen(''' =20 - if (compat_policy.deprecated_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) { + if (compat_policy.%(feat)s_output =3D=3D COMPAT_POLICY_OUTPUT_HIDE) { return; } -''') +''', + feat=3Df.name) =20 ret +=3D mcgen(''' =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 55f82d7389..b7b3fc0ce4 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -254,9 +254,11 @@ def doc_type(self): =20 def check(self, schema): QAPISchemaEntity.check(self, schema) - if 'deprecated' in [f.name for f in self.features]: - raise QAPISemError( - self.info, "feature 'deprecated' is not supported for type= s") + for feat in self.features: + if feat.is_special(): + raise QAPISemError( + self.info, + f"feature '{feat.name}' is not supported for types") =20 def describe(self): assert self.meta @@ -726,7 +728,7 @@ class QAPISchemaFeature(QAPISchemaMember): role =3D 'feature' =20 def is_special(self): - return self.name in ('deprecated') + return self.name in ('deprecated', 'unstable') =20 =20 class QAPISchemaObjectTypeMember(QAPISchemaMember): --=20 2.31.1