From: Greg Kurz <groug@kaod.org>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, pbonzini@redhat.com,
rth@twiddle.net, ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] pc: make sure that plugged CPUs are of the same type
Date: Tue, 10 Oct 2017 18:52:07 +0200 [thread overview]
Message-ID: <20171010185207.02018c52@bahia.lan> (raw)
In-Reply-To: <1507648660-201549-1-git-send-email-imammedo@redhat.com>
On Tue, 10 Oct 2017 17:17:40 +0200
Igor Mammedov <imammedo@redhat.com> wrote:
> heterogeneous cpus are not supported and hotplugging different
> cpu model crashes QEMU:
>
> qemu-system-x86_64 -cpu qemu64 -smp 1,maxcpus=2
> (qemu) device_add host-x86_64-cpu,socket-id=1,core-id=0,thread-id=0,id=foo
> (qemu) info cpus
> error: failed to get MSR 0x38d
> qemu-system-x86_64: target/i386/kvm.c:2121: kvm_get_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed.
> Aborted (core dumped)
>
> Gracefully fail hotplug process in case of user mistake.
>
> Reported-by: Greg Kurz <groug@kaod.org>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> v2:
> fix checkpatch error
> ---
(qemu) device_add host-x86_64-cpu,socket-id=1,core-id=0,thread-id=0,id=foo
Invalid CPU type, expected cpu type: 'qemu64-x86_64-cpu'
Tested-by: Greg Kurz <groug@kaod.org>
> 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 = X86_CPU(dev);
> + MachineState *ms = MACHINE(hotplug_dev);
> PCMachineState *pcms = PC_MACHINE(hotplug_dev);
>
> + 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 properties */
> if (cpu->apic_id == UNASSIGNED_APIC_ID) {
> int max_socket = (max_cpus - 1) / smp_threads / smp_cores;
prev parent reply other threads:[~2017-10-10 16:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 12:34 [Qemu-devel] [PATCH] pc: make sure that plugged CPUs are of the same type Igor Mammedov
2017-10-10 12:41 ` Paolo Bonzini
2017-10-10 14:52 ` no-reply
2017-10-10 15:17 ` [Qemu-devel] [PATCH v2] " Igor Mammedov
2017-10-10 15:22 ` Michael S. Tsirkin
2017-10-10 16:52 ` Greg Kurz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171010185207.02018c52@bahia.lan \
--to=groug@kaod.org \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).