From patchwork Tue Oct 13 23:04:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 302929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC2D8C433E7 for ; Tue, 13 Oct 2020 23:08:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E6E21D40 for ; Tue, 13 Oct 2020 23:08:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YqgbfBaI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45E6E21D40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTOk-00005o-EJ for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:08:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTME-0006N4-2c for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMB-0003Z3-L2 for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630322; h=from:from: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; bh=Pbjp8f4ua9Togwl/XXJ68jdNd0x8gpeRQ3cf/ImZEDY=; b=YqgbfBaIStQCFm+/uxrjY4vW+sbuhV1PJemDtLrpMSRt46NXHwzcbMvZa322I9J5sUrOWW Jy1P3p4ryFys0lsOO7nZj8X1OYHkR5lLt9r2u9K9DuzzwOjvAyT/FBDvT9oJj7BXWmqS+R wDqyJ1bXEXGASOPVVv2MyrNrRMwJg7A= 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-140-dXmLI0e-OO2haLkoXTIlfg-1; Tue, 13 Oct 2020 19:05:20 -0400 X-MC-Unique: dXmLI0e-OO2haLkoXTIlfg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C2A8802B4B; Tue, 13 Oct 2020 23:05:18 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72B772C31E; Tue, 13 Oct 2020 23:05:09 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] machine: machine_find_class() function Date: Tue, 13 Oct 2020 19:04:51 -0400 Message-Id: <20201013230457.150630-2-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 19:05:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move find_machine() from vl.c to core/machine.c and rename it to machine_find_class(), so it can be reused by other code. The function won't reuse the results of the previous object_class_get_list() call like it did in vl.c, but this shouldn't be a problem because the function is expected to be called only once during regular QEMU usage. Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 2 ++ hw/core/machine.c | 16 ++++++++++++++++ softmmu/vl.c | 17 +---------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index bf53e8a16e..922b710be3 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -43,6 +43,8 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); MemoryRegion *machine_consume_memdev(MachineState *machine, HostMemoryBackend *backend); +MachineClass *machine_find_class(const char *name); + /** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU diff --git a/hw/core/machine.c b/hw/core/machine.c index 7e2f4ec08e..879a596643 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1136,6 +1136,22 @@ void machine_run_board_init(MachineState *machine) machine_class->init(machine); } +MachineClass *machine_find_class(const char *name) +{ + g_autoptr(GSList) machines = object_class_get_list(TYPE_MACHINE, false); + GSList *el; + + for (el = machines; el; el = el->next) { + MachineClass *mc = el->data; + + if (!strcmp(mc->name, name) || !g_strcmp0(mc->alias, name)) { + return mc; + } + } + + return NULL; +} + static const TypeInfo machine_info = { .name = TYPE_MACHINE, .parent = TYPE_OBJECT, diff --git a/softmmu/vl.c b/softmmu/vl.c index 254ee5e525..b74f377a1c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1159,21 +1159,6 @@ static int usb_parse(const char *cmdline) MachineState *current_machine; -static MachineClass *find_machine(const char *name, GSList *machines) -{ - GSList *el; - - for (el = machines; el; el = el->next) { - MachineClass *mc = el->data; - - if (!strcmp(mc->name, name) || !g_strcmp0(mc->alias, name)) { - return mc; - } - } - - return NULL; -} - static MachineClass *find_default_machine(GSList *machines) { GSList *el; @@ -2341,7 +2326,7 @@ static MachineClass *machine_parse(const char *name, GSList *machines) exit(0); } - mc = find_machine(name, machines); + mc = machine_find_class(name); if (!mc) { error_report("unsupported machine type"); error_printf("Use -machine help to list supported machines\n"); From patchwork Tue Oct 13 23:04:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 302928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8583CC433E7 for ; Tue, 13 Oct 2020 23:08:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10D0521D40 for ; Tue, 13 Oct 2020 23:08:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ud8hNeM+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10D0521D40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTP0-0000lo-5B for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:08:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMI-0006S4-K0 for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59031) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMF-0003a7-82 for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630325; h=from:from: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; bh=/NUlmtHh+wg3YX9I3nJkvoDiBlyD3K/LW9vdgi90W2E=; b=Ud8hNeM+k/GXOwQSViN3iVlgQxRnLrDgBpMQlsKPoEsXrZdKNHKydirbh3uG+4/Dq2j03U QRJRwxX7ErINhFcrmMxSH3F/BubFkU2SwMRTmE3+G3qvLWnIRap9DtV68ni3ZWjjxkfKqe CSb4dnFWwXJ89X+xy5qCr9Ia5Dar7pY= 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-214-LfAEKcXSPtSzUnvCpPx-Ig-1; Tue, 13 Oct 2020 19:05:22 -0400 X-MC-Unique: LfAEKcXSPtSzUnvCpPx-Ig-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2039801FDA; Tue, 13 Oct 2020 23:05:19 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 993DF55790; Tue, 13 Oct 2020 23:05:19 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] i386: Add X86CPUModel.alias_of field Date: Tue, 13 Oct 2020 19:04:52 -0400 Message-Id: <20201013230457.150630-3-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 19:05:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of calling x86_cpu_class_get_alias_of(), just save the actual CPU model name in X86CPUModel and use it in `-cpu help`. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9eafbe3690..43e633ddd3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1647,6 +1647,12 @@ struct X86CPUModel { * This matters only for "-cpu help" and query-cpu-definitions */ bool is_alias; + /* + * Valid only if is_alias is true. + * If NULL, actual alias depend on machine type. + * If not NULL, name of actual CPU model this is an alias to. + */ + const char *alias_of; }; /* Get full model name for CPU version */ @@ -4927,14 +4933,13 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data) X86CPUClass *cc = X86_CPU_CLASS(oc); g_autofree char *name = x86_cpu_class_get_model_name(cc); g_autofree char *desc = g_strdup(cc->model_description); - g_autofree char *alias_of = x86_cpu_class_get_alias_of(cc); g_autofree char *model_id = x86_cpu_class_get_model_id(cc); - if (!desc && alias_of) { - if (cc->model && cc->model->version == CPU_VERSION_AUTO) { + if (!desc && cc->model && cc->model->is_alias) { + if (!cc->model->alias_of) { desc = g_strdup("(alias configured by machine type)"); } else { - desc = g_strdup_printf("(alias of %s)", alias_of); + desc = g_strdup_printf("(alias of %s)", cc->model->alias_of); } } if (!desc && cc->model && cc->model->note) { @@ -5418,6 +5423,7 @@ static void x86_register_cpudef_types(X86CPUDefinition *def) m->cpudef = def; m->version = CPU_VERSION_AUTO; m->is_alias = true; + m->alias_of = NULL; /* depends on machine type */ x86_register_cpu_model_type(def->name, m); /* Versioned models: */ @@ -5436,6 +5442,7 @@ static void x86_register_cpudef_types(X86CPUDefinition *def) am->cpudef = def; am->version = vdef->version; am->is_alias = true; + am->alias_of = g_strdup(name); x86_register_cpu_model_type(vdef->alias, am); } } From patchwork Tue Oct 13 23:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 302927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6548EC433DF for ; Tue, 13 Oct 2020 23:10:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 070DA21D40 for ; Tue, 13 Oct 2020 23:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PaENz9A0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 070DA21D40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTR0-0004BC-4Y for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:10:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMU-0006Y3-33 for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMM-0003bv-4e for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630332; h=from:from: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; bh=QTbX0B1zV000QcV8Vb8x3NBiMAjzCCHPhHUOANP/BZE=; b=PaENz9A0vsy13LhuDZHo+0HizNxFTw6l1i3ZG38AfwChjg9K6Q2swybVBlIJNCW5PMFavl GDdGijSP5hyCiO8O5R01oL8B8OwGwWQPZVcqRpxloTxEG+qKtutCl5rqPs4mPsUmZkXN5C nnhcnWNjWhtRvUafdANM8EAMJrNhG2c= 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-15-q1vk8DkEMYWJraXRdFxkiA-1; Tue, 13 Oct 2020 19:05:30 -0400 X-MC-Unique: q1vk8DkEMYWJraXRdFxkiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F9EF1074657; Tue, 13 Oct 2020 23:05:28 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFD797666A; Tue, 13 Oct 2020 23:05:20 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] i386: Replace x86_cpu_class_get_alias_of() with x86_cpu_model_resolve_alias() Date: Tue, 13 Oct 2020 19:04:53 -0400 Message-Id: <20201013230457.150630-4-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 02:06:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" New function is very similar to the old function, but it just takes a X86CPUModel as argument, and its name makes its purpose clearer. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 43e633ddd3..2c8dd3fa32 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4170,6 +4170,21 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model) return v; } +/* Resolve CPU model alias to actual CPU model name */ +static char *x86_cpu_model_resolve_alias(const X86CPUModel *model) +{ + X86CPUVersion version; + + if (!model->is_alias) { + return NULL; + } + version = x86_cpu_model_resolve_version(model); + if (version <= 0) { + return NULL; + } + return x86_cpu_versioned_model_name(model->cpudef, version); +} + void x86_cpu_change_kvm_default(const char *prop, const char *value) { PropValue *pv; @@ -4913,20 +4928,6 @@ static char *x86_cpu_class_get_model_id(X86CPUClass *xc) return r; } -static char *x86_cpu_class_get_alias_of(X86CPUClass *cc) -{ - X86CPUVersion version; - - if (!cc->model || !cc->model->is_alias) { - return NULL; - } - version = x86_cpu_model_resolve_version(cc->model); - if (version <= 0) { - return NULL; - } - return x86_cpu_versioned_model_name(cc->model->cpudef, version); -} - static void x86_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; @@ -5002,8 +5003,8 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions. */ - if (default_cpu_version != CPU_VERSION_LEGACY) { - info->alias_of = x86_cpu_class_get_alias_of(cc); + if (cc->model && default_cpu_version != CPU_VERSION_LEGACY) { + info->alias_of = x86_cpu_model_resolve_alias(cc->model); info->has_alias_of = !!info->alias_of; } From patchwork Tue Oct 13 23:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A2AEC43457 for ; Tue, 13 Oct 2020 23:10:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F206C22203 for ; Tue, 13 Oct 2020 23:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Eyqh2A30" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F206C22203 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTRN-00053Z-3W for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:10:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMW-0006ZI-1z for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMP-0003cC-Vo for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630333; h=from:from: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; bh=3m5u6RznFsKtqBBV59KVWcpK1ey1DAx8fco18NzU/lc=; b=Eyqh2A308DywvqJ0Ji6mEuwi2gVAh4lsEWkbBx2Fuwqd3TDW0u3aPglH+45lb1h7SxG0H8 LHfbTZGCFtBvgDXlXl/tNjY3yys3fpCrY9SjKs1lkEFPjZi7Qk885R+6NaH0SxBSY43DuT Vjdq6MUgb2ASxgsFNDmU+FGuEpU7vBc= 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-361-lX_C_LU4OYSt0zi8ng3Fjg-1; Tue, 13 Oct 2020 19:05:31 -0400 X-MC-Unique: lX_C_LU4OYSt0zi8ng3Fjg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D0EB56BE6; Tue, 13 Oct 2020 23:05:29 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 227BE76663; Tue, 13 Oct 2020 23:05:28 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] i386: Add default_version parameter to CPU version functions Date: Tue, 13 Oct 2020 19:04:54 -0400 Message-Id: <20201013230457.150630-5-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 02:06:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Currently, the functions that resolve CPU model versions (x86_cpu_model_resolve_version(), x86_cpu_model_resolve_alias()) need a machine to be initialized first. Get rid of this requirement by making those functions get an explicit default_version argument. No behavior changes are introduced by this patch, as all callers are being changed to use default_cpu_version as argument. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2c8dd3fa32..c78b2abfb8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4158,11 +4158,12 @@ static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model) } /* Return the actual version being used for a specific CPU model */ -static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model) +static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model, + X86CPUVersion default_version) { X86CPUVersion v = model->version; if (v == CPU_VERSION_AUTO) { - v = default_cpu_version; + v = default_version; } if (v == CPU_VERSION_LATEST) { return x86_cpu_model_last_version(model); @@ -4171,14 +4172,15 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model) } /* Resolve CPU model alias to actual CPU model name */ -static char *x86_cpu_model_resolve_alias(const X86CPUModel *model) +static char *x86_cpu_model_resolve_alias(const X86CPUModel *model, + X86CPUVersion default_version) { X86CPUVersion version; if (!model->is_alias) { return NULL; } - version = x86_cpu_model_resolve_version(model); + version = x86_cpu_model_resolve_version(model, default_version); if (version <= 0) { return NULL; } @@ -5004,7 +5006,8 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) * doesn't break compatibility with previous QEMU versions. */ if (cc->model && default_cpu_version != CPU_VERSION_LEGACY) { - info->alias_of = x86_cpu_model_resolve_alias(cc->model); + info->alias_of = x86_cpu_model_resolve_alias(cc->model, + default_cpu_version); info->has_alias_of = !!info->alias_of; } @@ -5075,7 +5078,8 @@ static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props) static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model) { const X86CPUVersionDefinition *vdef; - X86CPUVersion version = x86_cpu_model_resolve_version(model); + X86CPUVersion version = x86_cpu_model_resolve_version(model, + default_cpu_version); if (version == CPU_VERSION_LEGACY) { return; From patchwork Tue Oct 13 23:04:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2905EC433E7 for ; Tue, 13 Oct 2020 23:08:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AAC5D21D40 for ; Tue, 13 Oct 2020 23:08:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VD0zdOVI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAC5D21D40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTPL-00018Z-PP for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:08:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMa-0006hk-Pf for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMX-0003iq-KE for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630343; h=from:from: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; bh=orSIgJvDF9xxjYGHgN+WlMbsHDPWVWiupoDqov+tdLA=; b=VD0zdOVIhCCWwsZJNR1HTEIlLEHQYgXuJ8miuDwqoaeJCQyRMxqBRjr07Up4LTr8a+a7IQ DP57nMufwPeVHahbnFT2vD7LsfQQdt0R3w/FT7sphmjKgBOJEz4le2lvTPycMmN72w6JyG CUWbln4bTlu6WOoYXJT+fcFw82vE5J8= 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-409-xFOAd2c9P8-16GGMaZ4lVg-1; Tue, 13 Oct 2020 19:05:40 -0400 X-MC-Unique: xFOAd2c9P8-16GGMaZ4lVg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEAFB80B71A; Tue, 13 Oct 2020 23:05:37 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C9075C1A3; Tue, 13 Oct 2020 23:05:30 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] i386: Wrap QMP code in !CONFIG_USER_ONLY Date: Tue, 13 Oct 2020 19:04:55 -0400 Message-Id: <20201013230457.150630-6-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 02:06:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The QMP code was never called by *-user, and we will add machine-type-specific code there, so add #ifdefs to make it safe. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c78b2abfb8..bf4b4a4812 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4171,6 +4171,7 @@ static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *model, return v; } +#ifndef CONFIG_USER_ONLY /* Resolve CPU model alias to actual CPU model name */ static char *x86_cpu_model_resolve_alias(const X86CPUModel *model, X86CPUVersion default_version) @@ -4186,6 +4187,7 @@ static char *x86_cpu_model_resolve_alias(const X86CPUModel *model, } return x86_cpu_versioned_model_name(model->cpudef, version); } +#endif void x86_cpu_change_kvm_default(const char *prop, const char *value) { @@ -4838,6 +4840,7 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, visit_type_strList(v, "unavailable-features", &result, errp); } +#ifndef CONFIG_USER_ONLY /* Check for missing features that may prevent the CPU class from * running using the current machine and accelerator. */ @@ -4876,6 +4879,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, object_unref(OBJECT(xc)); } +#endif /* Print all cpuid feature names in featureset */ @@ -4985,6 +4989,7 @@ void x86_cpu_list(void) g_list_free(names); } +#ifndef CONFIG_USER_ONLY static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; @@ -5025,6 +5030,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) g_slist_free(list); return cpu_list; } +#endif static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) From patchwork Tue Oct 13 23:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6865AC433DF for ; Tue, 13 Oct 2020 23:10:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C58221D40 for ; Tue, 13 Oct 2020 23:10:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Slv4xx6l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C58221D40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTRC-0004dG-0p for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:10:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMh-0006ws-Qi for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMg-0003k5-8h for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:05:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630353; h=from:from: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; bh=nFHqLdQ1LZr/q2BKzU1o9GdIbvc7LjYhDm97t9aU/Ro=; b=Slv4xx6lTN/Tt67rz9tdR63h0d29T7P1f5LbEcgD/MZCfgy4Nl1zf/mut/DBBov/t/itXL h2jL0bq8HQxuPWaShOjSCuhF/GOcBIltUbAl5PxDwxyfUEktjz9ZDM8XPXepEfu3cLdk4+ 32xkaJpJIRSGSTnKkTwcv9fSOEiE8Kg= 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-263-nDWHKgk1NNGLyyIPI98Yhw-1; Tue, 13 Oct 2020 19:05:49 -0400 X-MC-Unique: nDWHKgk1NNGLyyIPI98Yhw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83A531074659; Tue, 13 Oct 2020 23:05:47 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43F5E19C71; Tue, 13 Oct 2020 23:05:40 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] i386: Don't use default_cpu_version inside x86_cpu_definition_entry() Date: Tue, 13 Oct 2020 19:04:56 -0400 Message-Id: <20201013230457.150630-7-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 02:06:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will change query-cpu-definitions to have a new `machine` parameter. Move the code that reads default_cpu_version to qmp_query_cpu_definitions() to make that easier to implement. This patch shouldn't introduce any behavior change. Results of query-cpu-definition will be exactly the same. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bf4b4a4812..0807d12ffa 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4990,11 +4990,16 @@ void x86_cpu_list(void) } #ifndef CONFIG_USER_ONLY +typedef struct X86CPUDefinitionArgs { + CpuDefinitionInfoList *cpu_list; + X86CPUVersion default_version; +} X86CPUDefinitionArgs; + static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; X86CPUClass *cc = X86_CPU_CLASS(oc); - CpuDefinitionInfoList **cpu_list = user_data; + X86CPUDefinitionArgs *args = user_data; CpuDefinitionInfoList *entry; CpuDefinitionInfo *info; @@ -5010,25 +5015,27 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) * Old machine types won't report aliases, so that alias translation * doesn't break compatibility with previous QEMU versions. */ - if (cc->model && default_cpu_version != CPU_VERSION_LEGACY) { + if (cc->model && args->default_version != CPU_VERSION_LEGACY) { info->alias_of = x86_cpu_model_resolve_alias(cc->model, - default_cpu_version); + args->default_version); info->has_alias_of = !!info->alias_of; } entry = g_malloc0(sizeof(*entry)); entry->value = info; - entry->next = *cpu_list; - *cpu_list = entry; + entry->next = args->cpu_list; + args->cpu_list = entry; } CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { - CpuDefinitionInfoList *cpu_list = NULL; + X86CPUDefinitionArgs args = { .cpu_list = NULL }; GSList *list = get_sorted_cpu_model_list(); - g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list); + + args.default_version = default_cpu_version; + g_slist_foreach(list, x86_cpu_definition_entry, &args); g_slist_free(list); - return cpu_list; + return args.cpu_list; } #endif From patchwork Tue Oct 13 23:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 302926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C36EC433E7 for ; Tue, 13 Oct 2020 23:10:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 137FE21D7F for ; Tue, 13 Oct 2020 23:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h2xLKkFG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 137FE21D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSTRM-00051F-60 for qemu-devel@archiver.kernel.org; Tue, 13 Oct 2020 19:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSTMv-00077Q-39 for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:06:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSTMr-0003ky-Tg for qemu-devel@nongnu.org; Tue, 13 Oct 2020 19:06:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602630362; h=from:from: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; bh=JuXZUizPitfToIYjvGSlfEdgnZ1Kh4hY1IZ1XTdd/j0=; b=h2xLKkFG2crMUS9nzy9P4mZCiD2Lt7/0iGzOtk1MTQCEz8vJ8HC96e9i+BrN3KB2uX3sdR GgG5RzBV2cdC2iOZZyPHubtvLtoXYh/NI1Fe04E5x/vhmtdn8IMJy38gBVmVpDATkvN6Ci w9Lgal2F6fXDXY9b+uIao0kX7T2S1W4= 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-412-i9SzE-LQPSeay-a6hoV3Bw-1; Tue, 13 Oct 2020 19:05:57 -0400 X-MC-Unique: i9SzE-LQPSeay-a6hoV3Bw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 841A11007464; Tue, 13 Oct 2020 23:05:55 +0000 (UTC) Received: from localhost (ovpn-66-44.rdu2.redhat.com [10.10.66.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A83276663; Tue, 13 Oct 2020 23:05:48 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] cpu: Add `machine` parameter to query-cpu-definitions Date: Tue, 13 Oct 2020 19:04:57 -0400 Message-Id: <20201013230457.150630-8-ehabkost@redhat.com> In-Reply-To: <20201013230457.150630-1-ehabkost@redhat.com> References: <20201013230457.150630-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/13 19:05:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Thomas Huth , Markus Armbruster , Wainer dos Santos Moschetta , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Aleksandar Rikalo , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Cleber Rosa , Jiri Denemark , David Gibson , "Daniel P. Berrange" , Cornelia Huck , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The new parameter can be used by management software to query for CPU model alias information for multiple machines without restarting QEMU. Signed-off-by: Eduardo Habkost --- Changes v1 -> v2: * Rewrite documentation, with suggestions from Markus --- qapi/machine-target.json | 14 ++++++- target/arm/helper.c | 4 +- target/i386/cpu.c | 24 ++++++++++- target/mips/helper.c | 4 +- target/s390x/cpu_models.c | 4 +- target/ppc/translate_init.c.inc | 4 +- tests/acceptance/x86_cpu_model_versions.py | 48 ++++++++++++++++++++++ 7 files changed, 95 insertions(+), 7 deletions(-) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 698850cc78..211cb2d7c9 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -282,6 +282,10 @@ # # @alias-of: Name of CPU model this model is an alias for. The target of the # CPU model alias may change depending on the machine type. +# If the @machine argument was provided to query-cpu-definitions, +# alias information for that machine type will be returned. +# If @machine is not provided, alias information for +# the current machine will be returned. # Management software is supposed to translate CPU model aliases # in the VM configuration, because aliases may stop being # migration-safe in the future (since 4.1) @@ -318,9 +322,17 @@ # # Return a list of supported virtual CPU definitions # +# @machine: Name of machine type. The value of the @alias-of field +# is machine-specific. This overrides the machine type +# used to look up that information. This can be used +# to query machine-specific CPU model aliases without +# restarting QEMU (since 5.2) +# # Returns: a list of CpuDefInfo # # Since: 1.2.0 ## -{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], +{ 'command': 'query-cpu-definitions', + 'data': { '*machine': 'str' }, + 'returns': ['CpuDefinitionInfo'], 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } diff --git a/target/arm/helper.c b/target/arm/helper.c index cd0779ff5f..fc339a19ba 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8276,7 +8276,9 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data) *cpu_list = entry; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(bool has_machine, + const char *machine, + Error **errp) { CpuDefinitionInfoList *cpu_list = NULL; GSList *list; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0807d12ffa..d78ff6a563 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -56,6 +56,7 @@ #ifndef CONFIG_USER_ONLY #include "exec/address-spaces.h" #include "hw/i386/apic_internal.h" +#include "hw/i386/pc.h" #include "hw/boards.h" #endif @@ -4187,6 +4188,13 @@ static char *x86_cpu_model_resolve_alias(const X86CPUModel *model, } return x86_cpu_versioned_model_name(model->cpudef, version); } + +static X86CPUVersion default_cpu_version_for_machine(MachineClass *mc) +{ + PCMachineClass *pcmc = + (PCMachineClass *)object_class_dynamic_cast(OBJECT_CLASS(mc), TYPE_PC_MACHINE); + return pcmc ? pcmc->default_cpu_version : 1; +} #endif void x86_cpu_change_kvm_default(const char *prop, const char *value) @@ -5027,12 +5035,24 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data) args->cpu_list = entry; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(bool has_machine, + const char *machine, + Error **errp) { X86CPUDefinitionArgs args = { .cpu_list = NULL }; GSList *list = get_sorted_cpu_model_list(); - args.default_version = default_cpu_version; + if (!has_machine) { + args.default_version = default_cpu_version; + } else { + MachineClass *mc = machine_find_class(machine); + if (!mc) { + error_setg(errp, "Machine type '%s' not found", machine); + return NULL; + } + args.default_version = default_cpu_version_for_machine(mc); + } + g_slist_foreach(list, x86_cpu_definition_entry, &args); g_slist_free(list); return args.cpu_list; diff --git a/target/mips/helper.c b/target/mips/helper.c index afd78b1990..33351e9578 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -1518,7 +1518,9 @@ static void mips_cpu_add_definition(gpointer data, gpointer user_data) *cpu_list = entry; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(bool has_machine, + const char *machine, + Error **errp) { CpuDefinitionInfoList *cpu_list = NULL; GSList *list; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index ca484bfda7..19ccbd50ea 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -456,7 +456,9 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque) *cpu_list = entry; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(bool has_machine, + const char *machine, + Error **errp) { struct CpuDefinitionInfoListData list_data = { .list = NULL, diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc index bb66526280..0d31da0c7f 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10635,7 +10635,9 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) *first = entry; } -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +CpuDefinitionInfoList *qmp_query_cpu_definitions(bool has_machine, + const char *machine, + Error **errp) { CpuDefinitionInfoList *cpu_list = NULL; GSList *list; diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/x86_cpu_model_versions.py index 01ff614ec2..7fb17d00ba 100644 --- a/tests/acceptance/x86_cpu_model_versions.py +++ b/tests/acceptance/x86_cpu_model_versions.py @@ -238,6 +238,54 @@ class X86CPUModelAliases(avocado_qemu.Test): self.validate_aliases(cpus) + def test_machine_arg_none(self): + """Check results using explicit machine=none argument""" + vm1 = self.get_vm() + vm1.add_args('-S') + vm1.set_machine('pc-i440fx-4.0') + vm1.launch() + cpus1 = dict((m['name'], m.get('alias-of')) + for m in vm1.command('query-cpu-definitions', + machine='none')) + vm1.shutdown() + + vm2 = self.get_vm() + vm2.add_args('-S') + vm2.set_machine('none') + vm2.launch() + cpus2 = dict((m['name'], m.get('alias-of')) + for m in vm2.command('query-cpu-definitions')) + vm1.shutdown() + + self.assertEquals(cpus1, cpus2) + + def test_machine_arg_4_1(self): + """Check results using explicit machine=pc-i440fx-4.1 argument""" + vm1 = self.get_vm() + vm1.add_args('-S') + vm1.set_machine('pc-i440fx-4.0') + vm1.launch() + cpus1 = dict((m['name'], m.get('alias-of')) + for m in vm1.command('query-cpu-definitions', + machine='pc-i440fx-4.1')) + vm1.shutdown() + + vm2 = self.get_vm() + vm2.add_args('-S') + vm2.set_machine('pc-i440fx-4.1') + vm2.launch() + cpus2 = dict((m['name'], m.get('alias-of')) + for m in vm2.command('query-cpu-definitions')) + vm1.shutdown() + + self.assertEquals(cpus1, cpus2) + + def test_invalid_machine(self): + self.vm.add_args('-S') + self.vm.launch() + r = self.vm.qmp('query-cpu-definitions', machine='invalid-machine-123') + self.assertIn('error', r) + class CascadelakeArchCapabilities(avocado_qemu.Test): """