From nobody Sat May 18 22:54:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678788085; cv=none; d=zohomail.com; s=zohoarc; b=WQFvUfgCQSGUCHy60PyqQ3OMm5sQyxIvNcqItNP7ttuUlKuX45X5I6IhgNrqDMhB2kkY+WOhawxdQejc6ldc0T2YCXFmHtDmqPlP34QkL1uV1MqG0bByTVjlSXbzqLggaaRGfliYo+QNKg0RCwnQaIrCWu+3UId2HJAfQ2L3/a8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678788085; h=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=qF9jjJl3NXaXDkwWS9hxMQNCzJQHYjOGYR5/UWEQ8Hs=; b=cvwuc+3lI7itprvjWkPYnEIAC+4jvQ74+ABxVWHQZ4dn9BbTIOmdfKsXjaL0UDzyQF2ZGJ1q2ftKkjqhasysnOax8WtwJ1XIR2NEGDHpzvQZ5B5pE7JmDROZoXUTpjh+PTYT8j8KKFVdUGPdYx/2hHkN7rRlx0cTmIbu6QiCwys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678788085974190.50791733172207; Tue, 14 Mar 2023 03:01:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc1Ss-0008U3-Ci; Tue, 14 Mar 2023 06:01:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc1Sr-0008Tr-1E for qemu-devel@nongnu.org; Tue, 14 Mar 2023 06:01:05 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc1Sp-0002O6-1y for qemu-devel@nongnu.org; Tue, 14 Mar 2023 06:01:04 -0400 Received: by mail-qt1-x82e.google.com with SMTP id w23so16092146qtn.6 for ; Tue, 14 Mar 2023 03:01:02 -0700 (PDT) Received: from debian.hsd1.ma.comcast.net ([2601:182:cc00:77b0::675]) by smtp.gmail.com with ESMTPSA id j15-20020ac8404f000000b003b323387c1asm1288812qtl.18.2023.03.14.03.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 03:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678788061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qF9jjJl3NXaXDkwWS9hxMQNCzJQHYjOGYR5/UWEQ8Hs=; b=PshVovdAQb/UmvcofZ5vJM2ZCHZmFfg9iZIyj1tz4en1B/30AYPoj8A6RtsIPXCH9t p7zshIn2hUwhwQd8fovq99DYSonureM/OHhJYZeh9mVdpmxkHu0XFlHBRv/eme7YiRCK ifmISH1iGIdkLG8XK1U4CdWLQ2vLCiQswMOY0mUMzQz2MaxfgkTAgZl2uwc8PWneLb/g OHt8RRnrhNvhzmEBplVaJqTQzi5Aa89zhHdXXj6jsSkNH1lliYjuZVCOt68hq2hwrEE3 Qn4F9ryK+OcnrPpC0XLu2dDQXWcBZcnZNJg3DU90Jo296mmB4Er1wgBbvEp/Rb9vFI1x K4wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678788061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qF9jjJl3NXaXDkwWS9hxMQNCzJQHYjOGYR5/UWEQ8Hs=; b=YghHvgUObbeLjefdCMj1lZ7/WtDl56btS7FaEWACmIdV1/iOSJXQqy6d5tMYw90ISz i7cc6qZfsdSL/UwyJQUd7GXrgHngIftc/v9zVxTTkDkTyV8b85iDe3VQXwzha0LmZiUV SLu88xrCuoET3xKAC6Il98iPUol0PMXUHBauAR5svv2RZS0dSbyCRyxNWrzQA3frxg3X 6O2jMxAooCoXfzq1v1ajpdooXw6iMI2oSm/A5ldNmE4Zl6hgL0MxAdE/Bq5Zith/A2Lj dfs35vJprrI7e3pD8hJ3+yeLciV3caR/I5/Rn11PeJm8JFo8ZNAxLQY3F/s6hlH5C32d vuYw== X-Gm-Message-State: AO0yUKWuxIy93JP1zjvYOWgRpi3kKr45Ysr9NeEJ6FPmYow9AB2YuRDl S38ZNsGDGx3c1o7iTuuY0ojMk+cpF8HJ0A== X-Google-Smtp-Source: AK7set+FJedHzlOX0N81+bhjc/ne/rmyoSUYpIe67/elLF+8ynAAK6Iy9sXS0fFQM5lcR+EuOkNlQQ== X-Received: by 2002:a05:622a:54c:b0:3bf:d9d2:484f with SMTP id m12-20020a05622a054c00b003bfd9d2484fmr62889236qtx.11.1678788061550; Tue, 14 Mar 2023 03:01:01 -0700 (PDT) From: Dinah Baum To: qemu-devel@nongnu.org Cc: Dinah Baum , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Eric Blake , Markus Armbruster , Michael Roth Subject: [PATCH v2 1/3] qapi/machine-target: refactor machine-target Date: Tue, 14 Mar 2023 06:00:24 -0400 Message-Id: <20230314100026.536079-2-dinahbaum123@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230314100026.536079-1-dinahbaum123@gmail.com> References: <20230314100026.536079-1-dinahbaum123@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::82e; envelope-from=dinahbaum123@gmail.com; helo=mail-qt1-x82e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678788088101100003 Content-Type: text/plain; charset="utf-8" Moved architecture agnostic data types to their own file to avoid "attempt to use poisoned TARGET_*" error that results when including qapi header with commands that aren't defined for all architectures. Required to implement enabling `query-cpu-model-expansion` on all architectures Signed-off-by: Dinah Baum Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 1 + qapi/machine-target-common.json | 79 +++++++++++++++++++++++++++++++++ qapi/machine-target.json | 73 +----------------------------- qapi/meson.build | 1 + 4 files changed, 82 insertions(+), 72 deletions(-) create mode 100644 qapi/machine-target-common.json diff --git a/MAINTAINERS b/MAINTAINERS index 95c957d587..bc4a6ba399 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1750,6 +1750,7 @@ F: hw/core/numa.c F: hw/cpu/cluster.c F: qapi/machine.json F: qapi/machine-target.json +F: qapi/machine-target-common.json F: include/hw/boards.h F: include/hw/core/cpu.h F: include/hw/cpu/cluster.h diff --git a/qapi/machine-target-common.json b/qapi/machine-target-common.j= son new file mode 100644 index 0000000000..1e6da3177d --- /dev/null +++ b/qapi/machine-target-common.json @@ -0,0 +1,79 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython + +## +# =3D Common data types for machine target commands +## + +## +# @CpuModelInfo: +# +# Virtual CPU model. +# +# A CPU model consists of the name of a CPU definition, to which +# delta changes are applied (e.g. features added/removed). Most magic valu= es +# that an architecture might require should be hidden behind the name. +# However, if required, architectures can expose relevant properties. +# +# @name: the name of the CPU definition the model is based on +# @props: a dictionary of QOM properties to be applied +# +# Since: 2.8 +## +{ 'struct': 'CpuModelInfo', +'data': { 'name': 'str', + '*props': 'any' } } + +## +# @CpuModelExpansionType: +# +# An enumeration of CPU model expansion types. +# +# @static: Expand to a static CPU model, a combination of a static base +# model name and property delta changes. As the static base model= will +# never change, the expanded CPU model will be the same, independ= ent of +# QEMU version, machine type, machine options, and accelerator op= tions. +# Therefore, the resulting model can be used by tooling without h= aving +# to specify a compatibility machine - e.g. when displaying the "= host" +# model. The @static CPU models are migration-safe. + +# @full: Expand all properties. The produced model is not guaranteed to be +# migration-safe, but allows tooling to get an insight and work with +# model details. +# +# Note: When a non-migration-safe CPU model is expanded in static mode, so= me +# features enabled by the CPU model may be omitted, because they can= 't be +# implemented by a static CPU model definition (e.g. cache info pass= through and +# PMU passthrough in x86). If you need an accurate representation of= the +# features enabled by a non-migration-safe CPU model, use @full. If = you need a +# static representation that will keep ABI compatibility even when c= hanging QEMU +# version or machine-type, use @static (but keep in mind that some f= eatures may +# be omitted). +# +# Since: 2.8 +## +{ 'enum': 'CpuModelExpansionType', + 'data': [ 'static', 'full' ] } + +## +# @CpuModelCompareResult: +# +# An enumeration of CPU model comparison results. The result is usually +# calculated using e.g. CPU features or CPU generations. +# +# @incompatible: If model A is incompatible to model B, model A is not +# guaranteed to run where model B runs and the other way ar= ound. +# +# @identical: If model A is identical to model B, model A is guaranteed to= run +# where model B runs and the other way around. +# +# @superset: If model A is a superset of model B, model B is guaranteed to= run +# where model A runs. There are no guarantees about the other w= ay. +# +# @subset: If model A is a subset of model B, model A is guaranteed to run +# where model B runs. There are no guarantees about the other way. +# +# Since: 2.8 +## +{ 'enum': 'CpuModelCompareResult', + 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 2e267fa458..1cacfde88e 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -4,78 +4,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. =20 -## -# @CpuModelInfo: -# -# Virtual CPU model. -# -# A CPU model consists of the name of a CPU definition, to which -# delta changes are applied (e.g. features added/removed). Most magic valu= es -# that an architecture might require should be hidden behind the name. -# However, if required, architectures can expose relevant properties. -# -# @name: the name of the CPU definition the model is based on -# @props: a dictionary of QOM properties to be applied -# -# Since: 2.8 -## -{ 'struct': 'CpuModelInfo', - 'data': { 'name': 'str', - '*props': 'any' } } - -## -# @CpuModelExpansionType: -# -# An enumeration of CPU model expansion types. -# -# @static: Expand to a static CPU model, a combination of a static base -# model name and property delta changes. As the static base model= will -# never change, the expanded CPU model will be the same, independ= ent of -# QEMU version, machine type, machine options, and accelerator op= tions. -# Therefore, the resulting model can be used by tooling without h= aving -# to specify a compatibility machine - e.g. when displaying the "= host" -# model. The @static CPU models are migration-safe. - -# @full: Expand all properties. The produced model is not guaranteed to be -# migration-safe, but allows tooling to get an insight and work with -# model details. -# -# Note: When a non-migration-safe CPU model is expanded in static mode, so= me -# features enabled by the CPU model may be omitted, because they can= 't be -# implemented by a static CPU model definition (e.g. cache info pass= through and -# PMU passthrough in x86). If you need an accurate representation of= the -# features enabled by a non-migration-safe CPU model, use @full. If = you need a -# static representation that will keep ABI compatibility even when c= hanging QEMU -# version or machine-type, use @static (but keep in mind that some f= eatures may -# be omitted). -# -# Since: 2.8 -## -{ 'enum': 'CpuModelExpansionType', - 'data': [ 'static', 'full' ] } - -## -# @CpuModelCompareResult: -# -# An enumeration of CPU model comparison results. The result is usually -# calculated using e.g. CPU features or CPU generations. -# -# @incompatible: If model A is incompatible to model B, model A is not -# guaranteed to run where model B runs and the other way ar= ound. -# -# @identical: If model A is identical to model B, model A is guaranteed to= run -# where model B runs and the other way around. -# -# @superset: If model A is a superset of model B, model B is guaranteed to= run -# where model A runs. There are no guarantees about the other w= ay. -# -# @subset: If model A is a subset of model B, model A is guaranteed to run -# where model B runs. There are no guarantees about the other way. -# -# Since: 2.8 -## -{ 'enum': 'CpuModelCompareResult', - 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } +{ 'include': 'machine-target-common.json' } =20 ## # @CpuModelBaselineInfo: diff --git a/qapi/meson.build b/qapi/meson.build index 9fd480c4d8..48be47170f 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -38,6 +38,7 @@ qapi_all_modules =3D [ 'job', 'machine', 'machine-target', + 'machine-target-common', 'migration', 'misc', 'misc-target', --=20 2.30.2 From nobody Sat May 18 22:54:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678788097; cv=none; d=zohomail.com; s=zohoarc; b=mk+hA3NG+aYGQngMUKSstnfuUOoM5vnDw78ng10VjbDeAl4XrTuBTUYt3nSjcEMzOGvOsSv8MSkpDRmMH+8QL+DQSUvToe0XxCoEKSYjDLuZOfOGE3zuikRQnorYbY5+sLG5y4ZEb8ATgfL3YLmlc3vkKUK8mR6YMg0Yo0FSAi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678788097; h=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=z/nfq3nRfuNFJzOhx1eUcP2fB7Gic1+OBhEGEUosltA=; b=UdXyrpGjdjmxZ012ieVjzhaLtJdNSvM5nQuv2rxKAH5YRW/XNvMLd6LgPPfvRizWnvkJ21eZHFJcitKnGqNFzOJ779w07iKGPUnDAKA97FGkfIo3RpR0pKOEIkQrs5IeG+DtcCvUjXxkwHunPga/OJDOzqD5aog0OXFElE88hak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678788097317335.5598839206302; Tue, 14 Mar 2023 03:01:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc1T4-0000C6-Pl; Tue, 14 Mar 2023 06:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc1Su-0000A1-RH; Tue, 14 Mar 2023 06:01:08 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc1Ss-0002Ob-GS; Tue, 14 Mar 2023 06:01:08 -0400 Received: by mail-qt1-x836.google.com with SMTP id d7so16020569qtr.12; Tue, 14 Mar 2023 03:01:05 -0700 (PDT) Received: from debian.hsd1.ma.comcast.net ([2601:182:cc00:77b0::675]) by smtp.gmail.com with ESMTPSA id j15-20020ac8404f000000b003b323387c1asm1288812qtl.18.2023.03.14.03.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 03:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678788064; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z/nfq3nRfuNFJzOhx1eUcP2fB7Gic1+OBhEGEUosltA=; b=nXmWyg+tui03O2TxpJrOBHpn3O2Q8WsMKD3i4zvd9FxolgyL1A/7QOt3chano0w0W6 nLvyKE1kUS48IgaLvCnovrFrcFt0oL3IIVb4MpLnUid7Bvfimbfe4hQJx7+MgWwlGzLg tweq3eCoifp3cPO0Gdo9sLiw2L6ihP6oD39XwoeDf0bjR+TJadje1uMoP//PrKR2h2kH u9/dZCT2ti6acVmJfxbF/lQfMAl7o/agTxm50t/cmWX0dowxYWBx6J8z+r9M2OmCCM8C t2rwwqNt66Ba3RkRO+Oqgcemi1fzrF+eVQpPvx1CsnmiFgINJ9CPsM74ifiun3KKXc5Y Tagw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678788064; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z/nfq3nRfuNFJzOhx1eUcP2fB7Gic1+OBhEGEUosltA=; b=29Zfyxzx0MRcM0v6iWBQfEe2jC3khoMZxYDCkIc3NKUSToCWFuHVe0vfKnz2u7+0Y+ uw1kjceMkJW0sp+aLounm13PMw9RiLsKm5JHCWEt0XIgGbYnIAsg/vNmVbWTfq1qGPdp TiE0ejn88TWkfBaD3nSN+Nf1I2mi14A38udMDeryfi8pgP6H+JvKFR2VlXUzOWyPsc6L mzokMp3K6oRtpNDd8QHp6ijxKb46jeCcvoo5HTEeaF8bD+g1JlUvHCwUruJLiXadQYzs OnVoG6gTT7h/DIxPAHWG7zA/tha5ghhzdT8kHKPust/KRMY2dlFvTktgU9XLl9uhKwws 43mw== X-Gm-Message-State: AO0yUKVu/6Ju+CKyfl9LIXr5VNIMwdATgDxtFYJThLARyvFFrCW1Ss0b 3WhUyRtdVN0Uywtk53LPFTtgzvKFRUBwGA== X-Google-Smtp-Source: AK7set+VGoBCNtuaPdiboZbCxO3lhnRD8R+P9jFK3Ev5nPFCn7JEUJMSM6gu3Uejyivh/En9UHiuGA== X-Received: by 2002:ac8:57cd:0:b0:3b9:b619:42c1 with SMTP id w13-20020ac857cd000000b003b9b61942c1mr61965412qta.27.1678788063896; Tue, 14 Mar 2023 03:01:03 -0700 (PDT) From: Dinah Baum To: qemu-devel@nongnu.org Cc: Dinah Baum , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , Eric Blake , Markus Armbruster , Peter Maydell , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-s390x@nongnu.org (open list:S390 TCG CPUs) Subject: [PATCH v2 2/3] cpu, qapi, target/arm, i386, s390x: Generalize query-cpu-model-expansion Date: Tue, 14 Mar 2023 06:00:25 -0400 Message-Id: <20230314100026.536079-3-dinahbaum123@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230314100026.536079-1-dinahbaum123@gmail.com> References: <20230314100026.536079-1-dinahbaum123@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::836; envelope-from=dinahbaum123@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678788098059100001 Content-Type: text/plain; charset="utf-8" This patch enables 'query-cpu-model-expansion' on all architectures. Only architectures that implement the command will return results, others will return an error message as before. This patch lays the groundwork for parsing a -cpu cpu,help option as specified in https://gitlab.com/qemu-project/qemu/-/issues/1480 Signed-off-by: Dinah Baum --- cpu.c | 20 ++++++++++++ include/exec/cpu-common.h | 8 +++++ qapi/machine-target-common.json | 51 +++++++++++++++++++++++++++++ qapi/machine-target.json | 56 -------------------------------- target/arm/arm-qmp-cmds.c | 7 ++-- target/arm/cpu.h | 7 +++- target/i386/cpu-sysemu.c | 7 ++-- target/i386/cpu.h | 6 ++++ target/s390x/cpu.h | 7 ++++ target/s390x/cpu_models_sysemu.c | 6 ++-- 10 files changed, 108 insertions(+), 67 deletions(-) diff --git a/cpu.c b/cpu.c index 567b23af46..c09edc4556 100644 --- a/cpu.c +++ b/cpu.c @@ -291,6 +291,26 @@ void list_cpus(const char *optarg) #endif } =20 +CpuModelExpansionInfo *get_cpu_model_expansion_info(CpuModelExpansionType = type, + CpuModelInfo *model, + Error **errp) +{ + /* XXX: implement cpu_model_expansion for targets that still miss it */ +#if defined(cpu_model_expansion) + return cpu_model_expansion(type, model, errp); +#else + error_setg(errp, "Could not query cpu model information"); + return NULL; +#endif +} + +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, + CpuModelInfo *model, + Error **errp) +{ + return get_cpu_model_expansion_info(type, model, errp); +} + #if defined(CONFIG_USER_ONLY) void tb_invalidate_phys_addr(target_ulong addr) { diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 6feaa40ca7..ec6024dfde 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -7,6 +7,8 @@ #include "exec/hwaddr.h" #endif =20 +#include "qapi/qapi-commands-machine-target-common.h" + /** * vaddr: * Type wide enough to contain any #target_ulong virtual address. @@ -166,5 +168,11 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, extern int singlestep; =20 void list_cpus(const char *optarg); +typedef void (*cpu_model_expansion_func)(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp); +CpuModelExpansionInfo *get_cpu_model_expansion_info(CpuModelExpansionType = type, + CpuModelInfo *model, + Error **errp); =20 #endif /* CPU_COMMON_H */ diff --git a/qapi/machine-target-common.json b/qapi/machine-target-common.j= son index 1e6da3177d..44713e9935 100644 --- a/qapi/machine-target-common.json +++ b/qapi/machine-target-common.json @@ -77,3 +77,54 @@ ## { 'enum': 'CpuModelCompareResult', 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } + +## +# @CpuModelExpansionInfo: +# +# The result of a cpu model expansion. +# +# @model: the expanded CpuModelInfo. +# +# Since: 2.8 +## +{ 'struct': 'CpuModelExpansionInfo', + 'data': { 'model': 'CpuModelInfo' } } + +## +# @query-cpu-model-expansion: +# +# Expands a given CPU model (or a combination of CPU model + additional op= tions) +# to different granularities, allowing tooling to get an understanding wha= t a +# specific CPU model looks like in QEMU under a certain configuration. +# +# This interface can be used to query the "host" CPU model. +# +# The data returned by this command may be affected by: +# +# * QEMU version: CPU models may look different depending on the QEMU vers= ion. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine-type: CPU model may look different depending on the machine-t= ype. +# (Except for CPU models reported as "static" in query-cpu-definitions.) +# * machine options (including accelerator): in some architectures, CPU mo= dels +# may look different depending on machine and accelerator options. (Exce= pt for +# CPU models reported as "static" in query-cpu-definitions.) +# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd +# global properties may affect expansion of CPU models. Using +# query-cpu-model-expansion while using these is not advised. +# +# Some architectures may not support all expansion types. s390x supports +# "full" and "static". Arm only supports "full". +# +# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU mode= ls is +# not supported, if the model cannot be expanded, if the model co= ntains +# an unknown CPU definition name, unknown properties or properties +# with a wrong type. Also returns an error if an expansion type is +# not supported. +# +# Since: 2.8 +## +{ 'command': 'query-cpu-model-expansion', + 'data': { 'type': 'CpuModelExpansionType', + 'model': 'CpuModelInfo' }, + 'returns': 'CpuModelExpansionInfo' } + diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 1cacfde88e..cfc8b0c7f8 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -130,62 +130,6 @@ 'returns': 'CpuModelBaselineInfo', 'if': 'TARGET_S390X' } =20 -## -# @CpuModelExpansionInfo: -# -# The result of a cpu model expansion. -# -# @model: the expanded CpuModelInfo. -# -# Since: 2.8 -## -{ 'struct': 'CpuModelExpansionInfo', - 'data': { 'model': 'CpuModelInfo' }, - 'if': { 'any': [ 'TARGET_S390X', - 'TARGET_I386', - 'TARGET_ARM' ] } } - -## -# @query-cpu-model-expansion: -# -# Expands a given CPU model (or a combination of CPU model + additional op= tions) -# to different granularities, allowing tooling to get an understanding wha= t a -# specific CPU model looks like in QEMU under a certain configuration. -# -# This interface can be used to query the "host" CPU model. -# -# The data returned by this command may be affected by: -# -# * QEMU version: CPU models may look different depending on the QEMU vers= ion. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine-type: CPU model may look different depending on the machine-t= ype. -# (Except for CPU models reported as "static" in query-cpu-definitions.) -# * machine options (including accelerator): in some architectures, CPU mo= dels -# may look different depending on machine and accelerator options. (Exce= pt for -# CPU models reported as "static" in query-cpu-definitions.) -# * "-cpu" arguments and global properties: arguments to the -cpu option a= nd -# global properties may affect expansion of CPU models. Using -# query-cpu-model-expansion while using these is not advised. -# -# Some architectures may not support all expansion types. s390x supports -# "full" and "static". Arm only supports "full". -# -# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU mode= ls is -# not supported, if the model cannot be expanded, if the model co= ntains -# an unknown CPU definition name, unknown properties or properties -# with a wrong type. Also returns an error if an expansion type is -# not supported. -# -# Since: 2.8 -## -{ 'command': 'query-cpu-model-expansion', - 'data': { 'type': 'CpuModelExpansionType', - 'model': 'CpuModelInfo' }, - 'returns': 'CpuModelExpansionInfo', - 'if': { 'any': [ 'TARGET_S390X', - 'TARGET_I386', - 'TARGET_ARM' ] } } - ## # @CpuDefinitionInfo: # diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c index c8fa524002..e591e7c362 100644 --- a/target/arm/arm-qmp-cmds.c +++ b/target/arm/arm-qmp-cmds.c @@ -21,6 +21,7 @@ */ =20 #include "qemu/osdep.h" +#include "cpu.h" #include "hw/boards.h" #include "kvm_arm.h" #include "qapi/error.h" @@ -99,9 +100,9 @@ static const char *cpu_model_advertised_features[] =3D { NULL }; =20 -CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, - CpuModelInfo *model, - Error **errp) +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) { CpuModelExpansionInfo *expansion_info; const QDict *qdict_in =3D NULL; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c097cae988..d5dcc2ef11 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2660,7 +2660,12 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sy= nc); #define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU =20 #define cpu_list arm_cpu_list - +#ifdef CONFIG_SOFTMMU +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp); +#define cpu_model_expansion get_cpu_model_expansion +#endif /* ARM has the following "translation regimes" (as the ARM ARM calls them): * * If EL3 is 64-bit: diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index 28115edf44..c01c85839c 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -176,10 +176,9 @@ out: return xc; } =20 -CpuModelExpansionInfo * -qmp_query_cpu_model_expansion(CpuModelExpansionType type, - CpuModelInfo *model, - Error **errp) +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) { X86CPU *xc =3D NULL; Error *err =3D NULL; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d243e290d3..7ab633c642 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2209,6 +2209,12 @@ uint64_t cpu_get_tsc(CPUX86State *env); #endif =20 #define cpu_list x86_cpu_list +#ifdef CONFIG_SOFTMMU +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp); +#define cpu_model_expansion get_cpu_model_expansion +#endif =20 /* MMU modes definitions */ #define MMU_KSMAP_IDX 0 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7d6d01325b..e67a2b386e 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -799,6 +799,13 @@ void s390_cpu_list(void); void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga, const S390FeatInit feat_init); =20 +#ifdef CONFIG_SOFTMMU +/* cpu_models-sysemu.c */ +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp); +#define cpu_model_expansion get_cpu_model_expansion +#endif =20 /* helper.c */ #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index 63981bf36b..ef3845f11c 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -213,9 +213,9 @@ static void cpu_info_from_model(CpuModelInfo *info, con= st S390CPUModel *model, } } =20 -CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, - CpuModelInfo *model, - Error **errp) +CpuModelExpansionInfo *get_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) { Error *err =3D NULL; CpuModelExpansionInfo *expansion_info =3D NULL; --=20 2.30.2 From nobody Sat May 18 22:54:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678788159; cv=none; d=zohomail.com; s=zohoarc; b=I1mIT/Q8tzsDWccEPEzjtjexll3YOcc9CN+QfGRVtN8Wfnhg6lrGwO6+nvr6m8ntlyXyTGCeImTStr8l5RQ8T4KyJFDC9CeMLqB4TyBZLaoyh1BWu2ocU50x76UqGWAl3WvOEbjlAlRa63PpgV+TyyBiHGueGhXTht7OWRs9wdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678788159; h=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=hJuQ9Ot9Rr33pUg6sU0ac4LU04XE1Atyy4CooADGLEw=; b=GNBA+XRj61AkcpSA7DmF59QTp813Dx3zCl9YiIRAP7KTiNR6ynosHdy3lg2CviontOwYf0MxbbEPJv4COExIhCwebOmpoIIoAqI0Cf+AMYrzS5O6aY8JzxhuEj/ZA/fMIpoPNhTZt/nQInkpglUvOXcivRwPLRtw6A2qkMY5ztI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678788158911638.1327514515683; Tue, 14 Mar 2023 03:02:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc1TG-0000TZ-NB; Tue, 14 Mar 2023 06:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc1Sx-0000Bl-4z for qemu-devel@nongnu.org; Tue, 14 Mar 2023 06:01:12 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc1Su-0002P2-Ud for qemu-devel@nongnu.org; Tue, 14 Mar 2023 06:01:10 -0400 Received: by mail-qt1-x830.google.com with SMTP id c18so16092997qte.5 for ; Tue, 14 Mar 2023 03:01:08 -0700 (PDT) Received: from debian.hsd1.ma.comcast.net ([2601:182:cc00:77b0::675]) by smtp.gmail.com with ESMTPSA id j15-20020ac8404f000000b003b323387c1asm1288812qtl.18.2023.03.14.03.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 03:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678788067; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hJuQ9Ot9Rr33pUg6sU0ac4LU04XE1Atyy4CooADGLEw=; b=U4HYmaQkcVNoA2pQkG3yZSce/ecnEfJt8/kHATz6eNaibdWOrX5gaeigwE/prbAWgt Eo2IHm84lNgOXXZMpaDMjfu1eBjTD5OsOyd0ns1QnosoAMWqSLz4iZfJW0lmAHI/j7p0 esFVH1XVpe5uU6vE5HXNk5I5TTBR4GlZm0ejNhp9/1GksY1yM5FAd0I2ZpcZT2BCyd2z 14OeGwVAJ+RcpKwsSJNwiGUND5EF5iuX5IZBco0U4M9uH212EpNNETyxbK97rx8ud9pE 8t1SDAtD/bdw4uPCmt2G3dXB0+vWD8s2p5SCfvZVFFL6IpaJ/oOxaSPoamzWUcST3zmN K5ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678788067; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hJuQ9Ot9Rr33pUg6sU0ac4LU04XE1Atyy4CooADGLEw=; b=myfRLD8wLnbzt0876N4Mue7VZeZ5I947X8u2G9YSfYa5zwDpB5AnOr0CMQfl7gtxnl ZT5gHe9uNbNjEzDmaYpdsuTGsH7SxC/OqccXG2cv1oquZgayni6GDPUo8h10UfDR7HhZ BjZKD1Iucd+4dPnB3lsrNygugT/pagqKHtQVFpiZ070zpAwuyy03ByMEsjflW5x1cDEV BsxoSCljryosS0LXWmIcNAmPnxW11SGYdtaUtx28ZTky+OjG8PkcIBUkxC3Rrx0KFrHM 9hYJjcehOVu3Pseptv7r7wuGCAkosoPE0WibLg9aYRKwGUbf4PzmDbG3hC542dN4qMBY ymCg== X-Gm-Message-State: AO0yUKUUgmvbOjBrE8A50TKoXHnrkP3y+mjVyuL6tu1ivPaCHuvJIbYF Nq3COH37fenxuyb0di9hqMrIP+ZMmVwn1A== X-Google-Smtp-Source: AK7set8JkBW8/47NZyJNLKuEy+NQbLjFCz1kF3bfzAhrGKReGO6sppkY6BM5wWMdM+NWLdOP5PdU5Q== X-Received: by 2002:a05:622a:48:b0:3ba:1d8d:f6d0 with SMTP id y8-20020a05622a004800b003ba1d8df6d0mr68492382qtw.23.1678788067200; Tue, 14 Mar 2023 03:01:07 -0700 (PDT) From: Dinah Baum To: qemu-devel@nongnu.org Cc: Dinah Baum , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , Paolo Bonzini , Markus Armbruster Subject: [PATCH v2 3/3] cpu, qdict, vl: Enable printing options for CPU type Date: Tue, 14 Mar 2023 06:00:26 -0400 Message-Id: <20230314100026.536079-4-dinahbaum123@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230314100026.536079-1-dinahbaum123@gmail.com> References: <20230314100026.536079-1-dinahbaum123@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::830; envelope-from=dinahbaum123@gmail.com; helo=mail-qt1-x830.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678788160613100001 Content-Type: text/plain; charset="utf-8" Change parsing of -cpu argument to allow -cpu cpu,help to print options for the CPU type similar to how the '-device' option works. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1480 Signed-off-by: Dinah Baum --- cpu.c | 41 +++++++++++++++++++++++++++++++++++++++ include/exec/cpu-common.h | 2 ++ include/qapi/qmp/qdict.h | 2 ++ qemu-options.hx | 7 ++++--- qobject/qdict.c | 5 +++++ softmmu/vl.c | 36 ++++++++++++++++++++++++++++++++-- 6 files changed, 88 insertions(+), 5 deletions(-) diff --git a/cpu.c b/cpu.c index c09edc4556..fe33c51061 100644 --- a/cpu.c +++ b/cpu.c @@ -23,7 +23,9 @@ #include "exec/target_page.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "migration/vmstate.h" #ifdef CONFIG_USER_ONLY #include "qemu.h" @@ -42,6 +44,8 @@ #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" #include "qemu/accel.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qobject.h" =20 uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; @@ -311,6 +315,43 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(C= puModelExpansionType type, return get_cpu_model_expansion_info(type, model, errp); } =20 +void list_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) +{ + CpuModelExpansionInfo *expansion_info; + QDict *qdict; + QDictEntry *qdict_entry; + const char *key; + QObject *obj; + QType q_type; + GPtrArray *array; + int i; + const char *type_name; + + expansion_info =3D get_cpu_model_expansion_info(type, model, errp); + if (expansion_info) { + qdict =3D qobject_to(QDict, expansion_info->model->props); + if (qdict) { + qemu_printf("%s features:\n", model->name); + array =3D g_ptr_array_new(); + for (qdict_entry =3D (QDictEntry *)qdict_first(qdict); qdict_e= ntry; + qdict_entry =3D (QDictEntry *)qdict_next(qdict, qdict_ent= ry)) { + g_ptr_array_add(array, qdict_entry); + } + g_ptr_array_sort(array, (GCompareFunc)dict_key_compare); + for (i =3D 0; i < array->len; i++) { + qdict_entry =3D array->pdata[i]; + key =3D qdict_entry_key(qdict_entry); + obj =3D qdict_get(qdict, key); + q_type =3D qobject_type(obj); + type_name =3D QType_str(q_type); + qemu_printf(" %s=3D<%s>\n", key, type_name); + } + } + } +} + #if defined(CONFIG_USER_ONLY) void tb_invalidate_phys_addr(target_ulong addr) { diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index ec6024dfde..8fc05307ad 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -174,5 +174,7 @@ typedef void (*cpu_model_expansion_func)(CpuModelExpans= ionType type, CpuModelExpansionInfo *get_cpu_model_expansion_info(CpuModelExpansionType = type, CpuModelInfo *model, Error **errp); +void list_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, Error **errp); =20 #endif /* CPU_COMMON_H */ diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 82e90fc072..1ff9523a13 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -68,4 +68,6 @@ const char *qdict_get_try_str(const QDict *qdict, const c= har *key); =20 QDict *qdict_clone_shallow(const QDict *src); =20 +int dict_key_compare(QDictEntry **entry1, QDictEntry **entry2); + #endif /* QDICT_H */ diff --git a/qemu-options.hx b/qemu-options.hx index d42f60fb91..d5284b9330 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -169,11 +169,12 @@ SRST ERST =20 DEF("cpu", HAS_ARG, QEMU_OPTION_cpu, - "-cpu cpu select CPU ('-cpu help' for list)\n", QEMU_ARCH_ALL) + "-cpu cpu select CPU ('-cpu help' for list)\n" + " use '-cpu cpu,help' to print possible properties\n", = QEMU_ARCH_ALL) SRST ``-cpu model`` - Select CPU model (``-cpu help`` for list and additional feature - selection) + Select CPU model (``-cpu help`` and ``-cpu cpu,help``) for list and ad= ditional feature + selection ERST =20 DEF("accel", HAS_ARG, QEMU_OPTION_accel, diff --git a/qobject/qdict.c b/qobject/qdict.c index 8faff230d3..31407e62f6 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -447,3 +447,8 @@ void qdict_unref(QDict *q) { qobject_unref(q); } + +int dict_key_compare(QDictEntry **entry1, QDictEntry **entry2) +{ + return g_strcmp0(qdict_entry_key(*entry1), qdict_entry_key(*entry2)); +} diff --git a/softmmu/vl.c b/softmmu/vl.c index 3340f63c37..a9d70e559e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -500,6 +500,15 @@ static QemuOptsList qemu_action_opts =3D { }, }; =20 +static QemuOptsList qemu_cpu_opts =3D { + .name =3D "cpu", + .implied_opt_name =3D "cpu", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_cpu_opts.head), + .desc =3D { + { /* end of list */ } + }, +}; + const char *qemu_get_vm_name(void) { return qemu_name; @@ -1147,6 +1156,26 @@ static int device_init_func(void *opaque, QemuOpts *= opts, Error **errp) return 0; } =20 +static int cpu_help_func(void *opaque, QemuOpts *opts, Error **errp) +{ + CpuModelInfo *model; + + if (cpu_option && is_help_option(cpu_option)) { + list_cpus(cpu_option); + return 1; + } + + if (!cpu_option || !qemu_opt_has_help_opt(opts)) { + return 0; + } + + model =3D g_new0(CpuModelInfo, 1); + model->name =3D (char *)qemu_opt_get(opts, "cpu"); + /* TODO: handle other expansion cases */ + list_cpu_model_expansion(CPU_MODEL_EXPANSION_TYPE_FULL, model, errp); + return 1; +} + static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) { Error *local_err =3D NULL; @@ -2431,8 +2460,9 @@ static void qemu_process_help_options(void) * type and the user did not specify one, so that the user doesn't need * to say '-cpu help -machine something'. */ - if (cpu_option && is_help_option(cpu_option)) { - list_cpus(cpu_option); + Error *errp =3D NULL; + if (qemu_opts_foreach(qemu_find_opts("cpu"), + cpu_help_func, NULL, &errp)) { exit(0); } =20 @@ -2672,6 +2702,7 @@ void qemu_init(int argc, char **argv) qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); qemu_add_opts(&qemu_action_opts); + qemu_add_opts(&qemu_cpu_opts); module_call_init(MODULE_INIT_OPTS); =20 error_init(argv[0]); @@ -2723,6 +2754,7 @@ void qemu_init(int argc, char **argv) switch(popt->index) { case QEMU_OPTION_cpu: /* hw initialization will check this */ + qemu_opts_parse_noisily(qemu_find_opts("cpu"), optarg, tru= e); cpu_option =3D optarg; break; case QEMU_OPTION_hda: --=20 2.30.2