From nobody Thu Nov 13 23:37:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253376; cv=none; d=zohomail.com; s=zohoarc; b=ZD5sc1s2AHZD4/ANfGWm+eG+GwQfEge7DPRNNSuOEYPe+kPGXN9MhK96hw2giHG+pw4cPyCu/C0HLsfixZ9nqKQb6w7A6j+ujqpLBXYfgDIqv2Lwime1FkXhTeMmXKqwa5NHP6bKLx5vhMB+SG5vjZ0vKwYDgXsMQgVSXkznKk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253376; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jlo30X4GLrqRRWhmO6ugS7pBjmrmoB9UDccQD7F+uNk=; b=j7bhxmt0igO0xFrdPseCmLn4RIN5ORk3Q7SPObuEb1C2aE0y6nEwwymPTshxX1HDdr6qKEuxl6QbST0+o7nXlkTxhXNp7VPL4wYZEQxHZIP7X5ZRchx7bXpSAZqmZHyR6ftBrToOq7KUmy5qGAOixK9esNJizxqiN9HFXXxfgfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583253376844195.00923211885038; Tue, 3 Mar 2020 08:36:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-C3SSj9eGO8KIsMz4kCdcUw-1; Tue, 03 Mar 2020 11:36:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA862100DFD1; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9A925DA75; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 42DBD18034EE; Tue, 3 Mar 2020 16:36:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZG4s001310 for ; Tue, 3 Mar 2020 11:35:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 078535DA82; Tue, 3 Mar 2020 16:35:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3D7B5DA2C; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 16126113278C; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253375; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Jlo30X4GLrqRRWhmO6ugS7pBjmrmoB9UDccQD7F+uNk=; b=fK/r8qIaJ6a/d7eU5pvtGAbEw7JKcZxHIcOjIz51wbWwm2NaqCc8d7e5xdOuTkvUNVTXC3 KWYlvBMk+I9cG12u6BEr5FE3fGkDQSP8Um0nGshfFGXp3SvjdlsNeEVvXk87OlG01/kg8W qwmEvsRMznTt/mhyG8XOfpBtH2qAQH4= X-MC-Unique: C3SSj9eGO8KIsMz4kCdcUw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 27/30] qemu-options: New -compat to set policy for deprecated interfaces Date: Tue, 3 Mar 2020 17:35:02 +0100 Message-Id: <20200303163505.32041-28-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Policy is separate for input and output. Input policy can be "accept" (accept silently), or "reject" (reject the request with an error). Output policy can be "accept" (pass on unchanged), or "hide" (filter out the deprecated parts). Default is "accept". Policies other than "accept" are implemented later in this series. For now, -compat covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'deprecated'. We may want to extend it to cover semantic aspects, CLI, and experimental features. The option is experimental. Signed-off-by: Markus Armbruster --- qapi/compat.json | 51 ++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + include/qapi/compat-policy.h | 20 ++++++++++++++ qapi/qmp-dispatch.c | 3 +++ softmmu/vl.c | 17 ++++++++++++ qapi/Makefile.objs | 8 +++--- qemu-options.hx | 21 +++++++++++++++ 7 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 qapi/compat.json create mode 100644 include/qapi/compat-policy.h diff --git a/qapi/compat.json b/qapi/compat.json new file mode 100644 index 0000000000..fd6f8e932c --- /dev/null +++ b/qapi/compat.json @@ -0,0 +1,51 @@ +# -*- Mode: Python -*- + +## +# =3D Compatibility policy +## + +## +# @CompatPolicyInput: +# +# Policy for handling "funny" input. +# +# @accept: Accept silently +# @reject: Reject with an error +# +# Since: 5.0 +## +{ 'enum': 'CompatPolicyInput', + 'data': [ 'accept', 'reject' ] } + +## +# @CompatPolicyOutput: +# +# Policy for handling "funny" output. +# +# @accept: Pass on unchanged +# @hide: Filter out +# +# Since: 5.0 +## +{ 'enum': 'CompatPolicyOutput', + 'data': [ 'accept', 'hide' ] } + +## +# @CompatPolicy: +# +# Policy for handling deprecated management interfaces. +# +# This is intended for testing users of the management interfaces. +# +# Limitation: covers only syntactic aspects of QMP, i.e. stuff tagged +# with feature 'deprecated'. We may want to extend it to cover +# semantic aspects, CLI, and experimental features. +# +# @deprecated-input: how to handle deprecated input (default 'accept') +# @deprecated-output: how to handle deprecated output (default 'accept') +# +# Since: 5.0 +## +{ 'struct': 'CompatPolicy', + 'data': { '*deprecated-input': 'CompatPolicyInput', + '*deprecated-output': 'CompatPolicyOutput' } } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index fe980ce437..fa800042e0 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -98,6 +98,7 @@ { 'include': 'migration.json' } { 'include': 'transaction.json' } { 'include': 'trace.json' } +{ 'include': 'compat.json' } { 'include': 'control.json' } { 'include': 'introspect.json' } { 'include': 'qom.json' } diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h new file mode 100644 index 0000000000..8efb2c58aa --- /dev/null +++ b/include/qapi/compat-policy.h @@ -0,0 +1,20 @@ +/* + * Policy for handling "funny" management interfaces + * + * Copyright (C) 2019 Red Hat, Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#ifndef QAPI_COMPAT_POLICY_H +#define QAPI_COMPAT_POLICY_H + +#include "qapi/qapi-types-compat.h" + +extern CompatPolicy compat_policy; + +#endif diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index fb53687ce9..80beab517f 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" @@ -19,6 +20,8 @@ #include "sysemu/runstate.h" #include "qapi/qmp/qbool.h" =20 +CompatPolicy compat_policy; + static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oo= b, QObject **id, Error **errp) { diff --git a/softmmu/vl.c b/softmmu/vl.c index 5549f4b619..0d6b769587 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -26,6 +26,7 @@ #include "qemu-common.h" #include "qemu/units.h" #include "hw/qdev-properties.h" +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qemu-version.h" #include "qemu/cutils.h" @@ -104,6 +105,7 @@ #include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-visit-compat.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-run-state.h" @@ -3748,6 +3750,21 @@ void qemu_init(int argc, char **argv, char **envp) qemu_opt_get_bool(opts, "mem-lock", false); enable_cpu_pm =3D qemu_opt_get_bool(opts, "cpu-pm", false); break; + case QEMU_OPTION_compat: + { + CompatPolicy *opts; + Visitor *v; + + v =3D qobject_input_visitor_new_str(optarg, NULL, + &error_fatal); + + visit_type_CompatPolicy(v, NULL, &opts, &error_fatal); + QAPI_CLONE_MEMBERS(CompatPolicy, &compat_policy, opts); + + qapi_free_CompatPolicy(opts); + visit_free(v); + break; + } case QEMU_OPTION_msg: opts =3D qemu_opts_parse_noisily(qemu_find_opts("msg"), op= targ, false); diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 20fcc37c2c..6c71e5c701 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -5,10 +5,10 @@ util-obj-y +=3D opts-visitor.o qapi-clone-visitor.o util-obj-y +=3D qmp-event.o util-obj-y +=3D qapi-util.o =20 -QAPI_COMMON_MODULES =3D audio authz block-core block char common control c= rypto -QAPI_COMMON_MODULES +=3D dump error introspect job machine migration misc -QAPI_COMMON_MODULES +=3D net qdev qom rdma rocker run-state sockets tpm -QAPI_COMMON_MODULES +=3D trace transaction ui +QAPI_COMMON_MODULES =3D audio authz block-core block char common compat +QAPI_COMMON_MODULES +=3D control crypto dump error introspect job +QAPI_COMMON_MODULES +=3D machine migration misc net qdev qom rdma rocker +QAPI_COMMON_MODULES +=3D run-state sockets tpm trace transaction ui QAPI_TARGET_MODULES =3D machine-target misc-target QAPI_MODULES =3D $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) =20 diff --git a/qemu-options.hx b/qemu-options.hx index 084a1c1f8c..d02d6bfc15 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3360,6 +3360,27 @@ STEXI @table @option ETEXI =20 +DEF("compat", HAS_ARG, QEMU_OPTION_compat, + "-compat [deprecated-input=3Daccept|reject][,deprecated-output=3Daccep= t|hide]\n" + " Policy for handling deprecated management interfaces\= n", + QEMU_ARCH_ALL) +STEXI +@item -compat [deprecated-input=3D@var{input-policy}][,deprecated-output= =3D@var{output-policy}] +@findex -compat +Set policy for handling deprecated management interfaces (experimental): +@table @option +@item deprecated-input=3Daccept (default) +Accept deprecated commands and arguments +@item deprecated-input=3Dreject +Reject deprecated commands and arguments +@item deprecated-output=3Daccept (default) +Emit deprecated command results and events +@item deprecated-output=3Dhide +Suppress deprecated command results and events +@end table +Limitation: covers only syntactic aspects of QMP. +ETEXI + DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg, "-fw_cfg [name=3D],file=3D\n" " add named fw_cfg entry with contents from file\n" --=20 2.21.1