From nobody Thu Nov 6 19:47:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488214538334343.21588659240683; Mon, 27 Feb 2017 08:55:38 -0800 (PST) Received: from localhost ([::1]:54284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciOaH-0000Dw-2u for importer@patchew.org; Mon, 27 Feb 2017 11:55:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciO76-00087t-Pm for qemu-devel@nongnu.org; Mon, 27 Feb 2017 11:25:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciO75-0005JM-Nx for qemu-devel@nongnu.org; Mon, 27 Feb 2017 11:25:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciO75-0005J3-Hk for qemu-devel@nongnu.org; Mon, 27 Feb 2017 11:25:27 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA2EE8123E; Mon, 27 Feb 2017 16:25:27 +0000 (UTC) Received: from localhost (ovpn-116-24.gru2.redhat.com [10.97.116.24]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RGPQkl022306; Mon, 27 Feb 2017 11:25:27 -0500 From: Eduardo Habkost To: Peter Maydell Date: Mon, 27 Feb 2017 13:25:01 -0300 Message-Id: <20170227162501.29280-12-ehabkost@redhat.com> In-Reply-To: <20170227162501.29280-1-ehabkost@redhat.com> References: <20170227162501.29280-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 27 Feb 2017 16:25:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/11] i386: Improve query-cpu-model-expansion full mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Jiri Denemark , qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This keeps the same results on type=3Dstatic expansion, but make type=3Dfull expansion return every single QOM property on the CPU object that have a different value from the "base' CPU model, plus all the CPU feature flag properties. Cc: Jiri Denemark Message-Id: <20170222190029.17243-4-ehabkost@redhat.com> Tested-by: Jiri Denemark Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 139b7ea12e..89421c893b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2419,6 +2419,34 @@ static void x86_cpu_to_dict(X86CPU *cpu, QDict *prop= s) } } =20 +/* Convert CPU model data from X86CPU object to a property dictionary + * that can recreate exactly the same CPU model, including every + * writeable QOM property. + */ +static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props) +{ + ObjectPropertyIterator iter; + ObjectProperty *prop; + + object_property_iter_init(&iter, OBJECT(cpu)); + while ((prop =3D object_property_iter_next(&iter))) { + /* skip read-only or write-only properties */ + if (!prop->get || !prop->set) { + continue; + } + + /* "hotplugged" is the only property that is configurable + * on the command-line but will be set differently on CPUs + * created using "-cpu ... -smp ..." and by CPUs created + * on the fly by x86_cpu_from_model() for querying. Skip it. + */ + if (!strcmp(prop->name, "hotplugged")) { + continue; + } + x86_cpu_expand_prop(cpu, props, prop->name); + } +} + static void object_apply_props(Object *obj, QDict *props, Error **errp) { const QDictEntry *prop; @@ -2489,11 +2517,13 @@ arch_query_cpu_model_expansion(CpuModelExpansionTyp= e type, goto out; } =20 + props =3D qdict_new(); =20 switch (type) { case CPU_MODEL_EXPANSION_TYPE_STATIC: /* Static expansion will be based on "base" only */ base_name =3D "base"; + x86_cpu_to_dict(xc, props); break; case CPU_MODEL_EXPANSION_TYPE_FULL: /* As we don't return every single property, full expansion needs @@ -2501,9 +2531,7 @@ arch_query_cpu_model_expansion(CpuModelExpansionType = type, * properties on top of that. */ base_name =3D model->name; - if (model->has_props && model->props) { - props =3D qdict_clone_shallow(qobject_to_qdict(model->props)); - } + x86_cpu_to_dict_full(xc, props); break; default: error_setg(&err, "Unsupportted expansion type"); --=20 2.11.0.259.g40922b1