From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMrmE-0007ls-8F for qemu-devel@nongnu.org; Tue, 12 Jul 2016 03:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMrmB-0007BX-01 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 03:06:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41808 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMrmA-0007BF-R2 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 03:06:38 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6C73SWa086268 for ; Tue, 12 Jul 2016 03:06:33 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0b-001b2d01.pphosted.com with ESMTP id 243enrpv02-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Jul 2016 03:06:33 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jul 2016 17:06:28 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 044A52BB0057 for ; Tue, 12 Jul 2016 17:06:27 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6C76Qhc13959274 for ; Tue, 12 Jul 2016 17:06:26 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6C76Qjs017194 for ; Tue, 12 Jul 2016 17:06:26 +1000 Date: Tue, 12 Jul 2016 12:36:17 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <20160711033507.GN25522@in.ibm.com> <1468244550-33910-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468244550-33910-1-git-send-email-imammedo@redhat.com> Message-Id: <20160712070617.GO25522@in.ibm.com> Subject: Re: [Qemu-devel] [PATCH] VARIANT 1: reuse device compat logic to pick preffered CPU's migration instance_id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, david@gibson.dropbear.id.au, ehabkost@redhat.com, marcel@redhat.com, pbonzini@redhat.com On Mon, Jul 11, 2016 at 03:42:29PM +0200, Igor Mammedov wrote: > this approach i I preffer as it uses less per machine migration glue > and follows typical compat pattern for devices > > Signed-off-by: Igor Mammedov > Signed-off-by: Bharata B Rao > --- > exec.c | 7 +++++-- > hw/i386/pc.c | 10 +++++++--- > include/hw/compat.h | 6 +++++- > include/qom/cpu.h | 3 +++ > qom/cpu.c | 13 +++++++++++++ > 5 files changed, 33 insertions(+), 6 deletions(-) > > diff --git a/exec.c b/exec.c > index 0122ef7..79e1dcb 100644 > --- a/exec.c > +++ b/exec.c > @@ -670,6 +670,7 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > { > CPUClass *cc = CPU_GET_CLASS(cpu); > Error *local_err = NULL; > + int migration_id; > > cpu->as = NULL; > cpu->num_ases = 0; > @@ -708,11 +709,13 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > (void) cc; > cpu_list_unlock(); > #else > + migration_id = cc->use_migration_id > 0 ? > + cpu->migration_id : cpu->cpu_index; cc->use_migration_id is always -1 here (See explanation below) > if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { > - vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); > + vmstate_register(NULL, migration_id, &vmstate_cpu_common, cpu); > } > if (cc->vmsd != NULL) { > - vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); > + vmstate_register(NULL, migration_id, cc->vmsd, cpu); > } > #endif > } > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index cd1745e..f041279 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1040,9 +1040,10 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) > } > > static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id, > - Error **errp) > + Error **errp, int migration_id) > { > X86CPU *cpu = NULL; > + CPUState *cs = CPU(cpu); > Error *local_err = NULL; > > cpu = cpu_x86_create(cpu_model, &local_err); Assignment to cs should move here after cpu_x86_create. > @@ -1050,6 +1051,7 @@ static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id, > goto out; > } > > + 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); > > @@ -1093,7 +1095,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) > return; > } > > - cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err); > + cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err, id); > if (local_err) { > error_propagate(errp, local_err); > return; > @@ -1137,7 +1139,7 @@ void pc_cpus_init(PCMachineState *pcms) > pcms->possible_cpus->len++; > if (i < smp_cpus) { > cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i), > - &error_fatal); > + &error_fatal, i); > pcms->possible_cpus->cpus[i].cpu = CPU(cpu); > object_unref(OBJECT(cpu)); > } > @@ -2012,7 +2014,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) > PCMachineClass *pcmc = PC_MACHINE_CLASS(oc); > HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); > NMIClass *nc = NMI_CLASS(oc); > + CPUClass *cc = CPU_CLASS(object_class_by_name(TYPE_CPU)); > > + cc->use_migration_id = true; It is not clear as to how setting cc->use_migration_id here in machine class init would affect all CPUs. What I am observing is that the cc that we set here is different from the cc that we get via GET_CPU_CLASS(cpu) in cpu_exec_init(). Hence use_migration_id is never set for any CPUs that get created. Regards, Bharata.