From nobody Sat Feb 7 05:57:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1635139625; cv=none; d=zohomail.com; s=zohoarc; b=ISiTaEU4qNLHoTnfQ5cskbdyC3+P6GDsopwedNCPkXALPCPLGdhM+HuBJ5UCYYVSEc7UOeg9MgJ6yQbImAjZ056CVG0pQaJZ/ZhB4WWUl8gkANnFFnR1U4W46nq5kZKCWbjCLAbMS5LDE8ZQsMDvOyU/zFwiEKufIEzKI+h2kw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635139625; 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=/m+AypTWJYVTQCgIyqvbrAEciwDG3N/8VGi7fimUx0E=; b=dOihQX0I64NgEgHTKI/ESVjGkOc+ADJBIpa0nNzfJpK7kRNbZ8ERBw8FxfFd0zhqsxbKtqlxXW5xgkjx54mOfOD0ZUfpC1uQ/6yd3hFcmnCOxrH1nRPueBYu8bJISL9wVoDItP5eFrM+6opdfYVHlIQ8BRk8oqC8KP2g/A4rEro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1635139625950132.98590674400168; Sun, 24 Oct 2021 22:27:05 -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-63-29o7XtVyPHKDSeP0ZFTS9A-1; Mon, 25 Oct 2021 01:26:35 -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 CBBE88066F4; Mon, 25 Oct 2021 05:26:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF59613ABD; Mon, 25 Oct 2021 05:26:30 +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 7CB291832DF9; Mon, 25 Oct 2021 05:26:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19P5QS7g020333 for ; Mon, 25 Oct 2021 01:26:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id C415D69FBB; Mon, 25 Oct 2021 05:26:28 +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 7354069CBE; Mon, 25 Oct 2021 05:25:48 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EC99B11380DF; Mon, 25 Oct 2021 07:25:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635139625; 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=/m+AypTWJYVTQCgIyqvbrAEciwDG3N/8VGi7fimUx0E=; b=FPShQ9qLl45Os9OINgrWtLfnR7EvbdzBVJz7p8j3QPy/3iXB92l15GUWYoUExrg8DRo3aT e84Vssu1vUTTPjG60BHVFD3TrzD7K43XbqI2cOUGqtfvvnRamEqoMocb069PvR62xAJrnH pj/fl1dECYbJxZgAKzH8xHWET906wOg= X-MC-Unique: 29o7XtVyPHKDSeP0ZFTS9A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 9/9] qapi: Extend -compat to set policy for unstable interfaces Date: Mon, 25 Oct 2021 07:25:32 +0200 Message-Id: <20211025052532.3859634-10-armbru@redhat.com> In-Reply-To: <20211025052532.3859634-1-armbru@redhat.com> References: <20211025052532.3859634-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: 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, 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.13 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: 1635139626378100003 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 --- 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 b5c6564cbb..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