From nobody Mon Apr 29 12:15:33 2024 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.zohomail.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 1507648772191578.9831532498247; Tue, 10 Oct 2017 08:19:32 -0700 (PDT) Received: from localhost ([::1]:35586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1wJR-0007eI-Db for importer@patchew.org; Tue, 10 Oct 2017 11:19:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1wI6-0006xc-6f for qemu-devel@nongnu.org; Tue, 10 Oct 2017 11:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1wI0-0005XP-EX for qemu-devel@nongnu.org; Tue, 10 Oct 2017 11:17:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1wI0-0005Vo-80 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 11:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60D0986647; Tue, 10 Oct 2017 15:17:47 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BD4B60A9B; Tue, 10 Oct 2017 15:17:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 60D0986647 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 17:17:40 +0200 Message-Id: <1507648660-201549-1-git-send-email-imammedo@redhat.com> In-Reply-To: <1507638879-200718-1-git-send-email-imammedo@redhat.com> References: <1507638879-200718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 10 Oct 2017 15:17:47 +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] [PATCH v2] pc: make sure that plugged CPUs are of the same type 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: pbonzini@redhat.com, groug@kaod.org, rth@twiddle.net, ehabkost@redhat.com, mst@redhat.com 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" heterogeneous cpus are not supported and hotplugging different cpu model crashes QEMU: qemu-system-x86_64 -cpu qemu64 -smp 1,maxcpus=3D2 (qemu) device_add host-x86_64-cpu,socket-id=3D1,core-id=3D0,thread-id=3D0= ,id=3Dfoo (qemu) info cpus error: failed to get MSR 0x38d qemu-system-x86_64: target/i386/kvm.c:2121: kvm_get_msrs: Assertion `ret = =3D=3D cpu->kvm_msr_buf->nmsrs' failed. Aborted (core dumped) Gracefully fail hotplug process in case of user mistake. Reported-by: Greg Kurz Signed-off-by: Igor Mammedov Acked-by: Michael S. Tsirkin Tested-by: Greg Kurz --- v2: fix checkpatch error --- hw/i386/pc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 05985d4..8e307f7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1876,8 +1876,15 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, CPUArchId *cpu_slot; X86CPUTopoInfo topo; X86CPU *cpu =3D X86_CPU(dev); + MachineState *ms =3D MACHINE(hotplug_dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 + if (!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { + error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", + ms->cpu_type); + return; + } + /* if APIC ID is not set, set it based on socket/core/thread propertie= s */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { int max_socket =3D (max_cpus - 1) / smp_threads / smp_cores; --=20 2.7.4