From patchwork Tue Jul 12 11:08:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9225077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45E35604DB for ; Tue, 12 Jul 2016 11:09:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35DDA265F9 for ; Tue, 12 Jul 2016 11:09:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2935C27BFF; Tue, 12 Jul 2016 11:09:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D7D9265F9 for ; Tue, 12 Jul 2016 11:09:19 +0000 (UTC) Received: from localhost ([::1]:38986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMvYz-0000Kq-QV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jul 2016 07:09:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMvYg-0000Ki-GH for qemu-devel@nongnu.org; Tue, 12 Jul 2016 07:08:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMvYa-0000dC-FT for qemu-devel@nongnu.org; Tue, 12 Jul 2016 07:08:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMvYa-0000d0-9u for qemu-devel@nongnu.org; Tue, 12 Jul 2016 07:08:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 F3DC1C04D309; Tue, 12 Jul 2016 11:08:51 +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 int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6CB8l2w010815; Tue, 12 Jul 2016 07:08:50 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 12 Jul 2016 13:08:46 +0200 Message-Id: <1468321726-44455-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1468321726-44455-1-git-send-email-imammedo@redhat.com> References: <20160712070617.GO25522@in.ibm.com> <1468321726-44455-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 12 Jul 2016 11:08:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] pc: fix migration failure after cpu hot-unplung 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: marcel@redhat.com, pbonzini@redhat.com, bharata@linux.vnet.ibm.com, ehabkost@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP As described in commit: cpu: add migration_id to allow board to provide migration instance_id set CPUState::migration_id explictly to stable index in pcms->possible_cpus so that CPU's instance_id on target would match instance_id on source even if not the last added CPU is removed. Signed-off-by: Igor Mammedov --- hw/i386/pc.c | 9 ++++++--- include/hw/i386/pc.h | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f56e225..9e72eb3 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1040,13 +1040,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) } static X86CPU *pc_new_cpu(const char *typename, int64_t apic_id, - Error **errp) + Error **errp, int migration_id) { X86CPU *cpu = NULL; + CPUState *cs; Error *local_err = NULL; cpu = X86_CPU(object_new(typename)); + cs = CPU(cpu); + cs->migration_id = migration_id; object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err); object_property_set_bool(OBJECT(cpu), true, "realized", &local_err); @@ -1092,7 +1095,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) assert(pcms->possible_cpus->cpus[0].cpu); /* BSP is always present */ oc = OBJECT_CLASS(CPU_GET_CLASS(pcms->possible_cpus->cpus[0].cpu)); - cpu = pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); + cpu = pc_new_cpu(object_class_get_name(oc), apic_id, &local_err, id); if (local_err) { error_propagate(errp, local_err); return; @@ -1156,7 +1159,7 @@ void pc_cpus_init(PCMachineState *pcms) pcms->possible_cpus->len++; if (i < smp_cpus) { cpu = pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), - &error_fatal); + &error_fatal, i); pcms->possible_cpus->cpus[i].cpu = CPU(cpu); object_unref(OBJECT(cpu)); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 2123532..fea2961 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -373,6 +373,11 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "vmxnet3",\ .property = "romfile",\ .value = "",\ + },\ + { \ + .driver = TYPE_CPU, \ + .property = "use-migration-id", \ + .value = "off", \ }, #define PC_COMPAT_2_5 \