From nobody Tue May 7 08:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1572453275; cv=none; d=zoho.com; s=zohoarc; b=HEMDdKdsm6Ilg8WmNyznAjKiNnuxQNg9VpE/ivhExm9vKzis+Syqkx9v6FdA2JK8zz1E3RexPyR1bYorEyZ08kXE1V1agl39K1tJfpsPTxNhPnct7OS9Kz7dmTWWtXgI48OoVw582FXtHGGnTcwRyDIXrhqCAHIJQ0bo5s/84RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572453275; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jnCJ5gPpUWIku3UDe6WQ1zIvYHNHzA9OfIV7hT3Gh6A=; b=K610dkVdqnA7Lb9GWXjmzfp29s0qH7yZvFzQHhMBCtugxnzEmO9W8d9DynunKjtGdYDhdtblXY3ss8ZmIGolgGqH6ZEa3zgRh8vfIEkB/NJtUgHB0Km8SmqkQ9pj5C2CWNTmjTpy1F5nQzBNQX2DBKindiMlHzTUdWmZqnqhZa4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572453275116701.9998039953252; Wed, 30 Oct 2019 09:34:35 -0700 (PDT) Received: from localhost ([::1]:42534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPqvZ-0002Y7-JK for importer@patchew.org; Wed, 30 Oct 2019 12:34:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57466) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPquA-0001h2-0h for qemu-devel@nongnu.org; Wed, 30 Oct 2019 12:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPqu8-0007y0-LN for qemu-devel@nongnu.org; Wed, 30 Oct 2019 12:33:05 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:52785 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPqu7-0007Z6-HR; Wed, 30 Oct 2019 12:33:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 473DX64fdDz9sPd; Thu, 31 Oct 2019 03:32:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1572453174; bh=2Ut/jU05PVrItKTeJQ9DougQ62vrTiFKSOQcEp5RSiQ=; h=From:To:Cc:Subject:Date:From; b=NXBg3gorz0c0fLwr/RktbGlbPnY1V4iIF9dLv0fbL6XIVAnTNCnAkUhVPLtaCZjHi uduGDivtSA+k2QLMKvGvO8ykjT3YDNVwijMO0Qi+R6DyAE7EobFrqKAG3Ue7AsffyG 20/7QeNtnqYzgqXcZfV/MxFV71TSYC/mMsodBJhQ= From: David Gibson To: jdenemar@redhat.com, david@redhat.com Subject: [PATCH] spapr/kvm: Set default cpu model for all machine classes Date: Wed, 30 Oct 2019 17:32:43 +0100 Message-Id: <20191030163243.10644-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We have to set the default model of all machine classes, not just for the active one. Otherwise, "query-machines" will indicate the wrong CPU model ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type". s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for all machine classes". This patch applies a similar fix for the pseries-* machine types on ppc64. Doing a {"execute":"query-machines"} under KVM now results in { "hotpluggable-cpus": true, "name": "pseries-4.2", "numa-mem-supported": true, "default-cpu-type": "host-powerpc64-cpu", "is-default": true, "cpu-max": 1024, "deprecated": false, "alias": "pseries" }, { "hotpluggable-cpus": true, "name": "pseries-4.1", "numa-mem-supported": true, "default-cpu-type": "host-powerpc64-cpu", "cpu-max": 1024, "deprecated": false }, ... Libvirt probes all machines via "-machine none,accel=3Dkvm:tcg" and will currently see the wrong CPU model under KVM. Reported-by: Ji=C5=99i Denemark Cc: David Hildenbrand Cc: Igor Mammedov Reviewed-by: David Hildenbrand Reviewed-by: Greg Kurz Tested-by: Jiri Denemark --- target/ppc/kvm.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 7d2e8969ac..c77f9848ec 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -100,7 +100,7 @@ static bool kvmppc_is_pr(KVMState *ks) return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) !=3D 0; } =20 -static int kvm_ppc_register_host_cpu_type(MachineState *ms); +static int kvm_ppc_register_host_cpu_type(void); static void kvmppc_get_cpu_characteristics(KVMState *s); static int kvmppc_get_dec_bits(void); =20 @@ -147,7 +147,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) exit(1); } =20 - kvm_ppc_register_host_cpu_type(ms); + kvm_ppc_register_host_cpu_type(); =20 return 0; } @@ -2534,13 +2534,19 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) return pvr_pcc; } =20 -static int kvm_ppc_register_host_cpu_type(MachineState *ms) +static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->default_cpu_type =3D TYPE_HOST_POWERPC_CPU; +} + +static int kvm_ppc_register_host_cpu_type(void) { TypeInfo type_info =3D { .name =3D TYPE_HOST_POWERPC_CPU, .class_init =3D kvmppc_host_cpu_class_init, }; - MachineClass *mc =3D MACHINE_GET_CLASS(ms); PowerPCCPUClass *pvr_pcc; ObjectClass *oc; DeviceClass *dc; @@ -2552,10 +2558,9 @@ static int kvm_ppc_register_host_cpu_type(MachineSta= te *ms) } type_info.parent =3D object_class_get_name(OBJECT_CLASS(pvr_pcc)); type_register(&type_info); - if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) { - /* override TCG default cpu type with 'host' cpu model */ - mc->default_cpu_type =3D TYPE_HOST_POWERPC_CPU; - } + /* override TCG default cpu type with 'host' cpu model */ + object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE, + false, NULL); =20 oc =3D object_class_by_name(type_info.name); g_assert(oc); --=20 2.21.0