From nobody Mon Feb 9 23:15:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635416829; cv=none; d=zohomail.com; s=zohoarc; b=CxehajTWHjTGAz6kGuHCzQfaEL4A+esqBlC4yC9Y0Pr7Z5WaC+P30Ba+Kh9hypKfw40hlDvmCa6EXk0jZXFa7kaYM+xKDzMQKZVmAWVGSZsPE6vyQZstzsks0/irr3CJbhXt2LEiUQW8bXZqiQbbjvCmzdcGme6pQw/vcaWio0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635416829; 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=YEgvUnsaNMoPIQtAjp9F7s7FFZJwSRcVuDGcckVSrAY=; b=GE/82+Me5dqsQPvoyhPjCLhW4j+0aNYHdjiQ9fbUpsvwytLXC3RITGIXi01Y7BTRdP1tjoI5FodXO8JvS9IQq9SpI5aVn38VQ0gyDasK738zYtBlAIpVnZPIlkr75CxzQR3IJ78l1fB657JIWkPbJNsjnS1XgxFA9wxorWM9qAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635416829809355.4785200024653; Thu, 28 Oct 2021 03:27:09 -0700 (PDT) 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-49-yCkfWTRNO16Iqt0BdWlchw-1; Thu, 28 Oct 2021 06:26:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7ADC1005547; Thu, 28 Oct 2021 10:26:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96B1460CA0; Thu, 28 Oct 2021 10:26:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6537E4EA44; Thu, 28 Oct 2021 10:26:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19SAQ92f007565 for ; Thu, 28 Oct 2021 06:26:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 87F2E5BAE5; Thu, 28 Oct 2021 10:26:09 +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 AF27B60854; Thu, 28 Oct 2021 10:25:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 567BA11380DF; Thu, 28 Oct 2021 12:25:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635416828; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YEgvUnsaNMoPIQtAjp9F7s7FFZJwSRcVuDGcckVSrAY=; b=ib3y1wZnYbArQQDO25JzHyIW9qpzSzi6ar8TGw8nJxFCrrPdLTpi6ws1cxcuFNYpqWozki ntIgXV7FbjvricR+e39rFc8BnGTBS5E4Ye59WF6waLwuygnauUxUDgTf9wEW1Mdzr2DkiA BXzRZRCnT+W5Nk6rgdsy6K4KUt3PDMo= X-MC-Unique: yCkfWTRNO16Iqt0BdWlchw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 9/9] qapi: Extend -compat to set policy for unstable interfaces Date: Thu, 28 Oct 2021 12:25:20 +0200 Message-Id: <20211028102520.747396-10-armbru@redhat.com> In-Reply-To: <20211028102520.747396-1-armbru@redhat.com> References: <20211028102520.747396-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, quintela@redhat.com, libvir-list@redhat.com, eblake@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, philmd@redhat.com, jsnow@redhat.com, libguestfs@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635416830293100001 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 Reviewed-by: Eric Blake --- qapi/compat.json | 6 +++++- include/qapi/util.h | 1 + qapi/qmp-dispatch.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, 49 insertions(+), 12 deletions(-) diff --git a/qapi/compat.json b/qapi/compat.json index 74a8493d3d..9bc9804abb 100644 --- a/qapi/compat.json +++ b/qapi/compat.json @@ -47,9 +47,13 @@ # # @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') +# @unstable-output: how to handle unstable output (default 'accept') # # 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/qmp-dispatch.c b/qapi/qmp-dispatch.c index e29ade134c..c5c6e521a2 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -59,6 +59,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