All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
To: Igor Mammedov <imammedo@redhat.com>,
	Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, tangchen@cn.fujitsu.com,
	isimatu.yasuaki@jp.fujitsu.com, guz.fnst@cn.fujitsu.com,
	anshul.makkar@profitbricks.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common CPUClass.realizefn
Date: Fri, 6 Mar 2015 17:31:43 +0800	[thread overview]
Message-ID: <54F973FF.3060501@cn.fujitsu.com> (raw)
In-Reply-To: <20150306095352.28200482@nial.brq.redhat.com>


On 03/06/2015 04:53 PM, Igor Mammedov wrote:
> On Fri, 13 Feb 2015 18:25:28 +0800
> Zhu Guihua <zhugh.fnst@cn.fujitsu.com> wrote:
>
>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>
>> Move cpu vmstate register from cpu_exec_init into cpu_common_realizefn,
>> and use cc->get_arch_id as the instance id that suggested by Igor to
>> fix the migration issue.
>>
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
>> ---
>>   exec.c            | 25 ++++++++++++++++++-------
>>   include/qom/cpu.h |  2 ++
>>   qom/cpu.c         |  4 ++++
>>   3 files changed, 24 insertions(+), 7 deletions(-)
>>
>> diff --git a/exec.c b/exec.c
>> index 6dff7bc..8361591 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -513,10 +513,26 @@ void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as)
>>   }
>>   #endif
>>   
>> +void cpu_vmstate_register(CPUState *cpu)
>> +{
>> +    CPUClass *cc = CPU_GET_CLASS(cpu);
>> +    int cpu_index = cc->get_arch_id(cpu) + max_cpus;
> Why do you add max_cpus here?
Adding max_cpus is to avoid cpu_index equals comat_index which would
cause migration fails,  this reason is that find_se() always compares 
instance_id
with se->instance_id or se->alias_id when do migration.

Thanks,
Chen

>
>> +    int compat_index = cc->get_compat_arch_id(cpu);
>> +
>> +    if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
>> +        vmstate_register_with_alias_id(NULL, cpu_index, &vmstate_cpu_common,
>> +                                       cpu, compat_index, 3);
>> +    }
>> +
>> +    if (cc->vmsd != NULL) {
>> +        vmstate_register_with_alias_id(NULL, cpu_index, cc->vmsd,
>> +                                       cpu, compat_index, 3);
>> +    }
>> +}
>> +
>>   void cpu_exec_init(CPUArchState *env)
>>   {
>>       CPUState *cpu = ENV_GET_CPU(env);
>> -    CPUClass *cc = CPU_GET_CLASS(cpu);
>>       CPUState *some_cpu;
>>       int cpu_index;
>>   
>> @@ -539,18 +555,13 @@ void cpu_exec_init(CPUArchState *env)
>>   #if defined(CONFIG_USER_ONLY)
>>       cpu_list_unlock();
>>   #endif
>> -    if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
>> -        vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu);
>> -    }
>>   #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
>> +    CPUClass *cc = CPU_GET_CLASS(cpu);
>>       register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
>>                       cpu_save, cpu_load, env);
>>       assert(cc->vmsd == NULL);
>>       assert(qdev_get_vmsd(DEVICE(cpu)) == NULL);
>>   #endif
>> -    if (cc->vmsd != NULL) {
>> -        vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
>> -    }
>>   }
>>   
>>   #if defined(CONFIG_USER_ONLY)
>> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
>> index 2e68dd2..d0a50e2 100644
>> --- a/include/qom/cpu.h
>> +++ b/include/qom/cpu.h
>> @@ -565,6 +565,8 @@ void cpu_interrupt(CPUState *cpu, int mask);
>>   
>>   #endif /* USER_ONLY */
>>   
>> +void cpu_vmstate_register(CPUState *cpu);
>> +
>>   #ifdef CONFIG_SOFTMMU
>>   static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
>>                                            bool is_write, bool is_exec,
>> diff --git a/qom/cpu.c b/qom/cpu.c
>> index 83d7766..8e37045 100644
>> --- a/qom/cpu.c
>> +++ b/qom/cpu.c
>> @@ -302,6 +302,10 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
>>   {
>>       CPUState *cpu = CPU(dev);
>>   
>> +#if !defined(CONFIG_USER_ONLY)
>> +    cpu_vmstate_register(cpu);
>> +#endif
>> +
>>       if (dev->hotplugged) {
>>           cpu_synchronize_post_init(cpu);
>>           cpu_resume(cpu);
> .
>

  reply	other threads:[~2015-03-06  9:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 10:25 [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 01/10] cpu/apic: drop icc bus/bridge/ Zhu Guihua
2015-03-05 18:17   ` Eduardo Habkost
2015-03-06  3:10     ` Chen Fan
2015-03-06  9:35   ` Igor Mammedov
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 02/10] icc_bus: remove icc related files Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 03/10] cpu: introduce CpuTopoInfo structure for argument simplification Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 04/10] cpu: introduce get_compat_arch_id() method and override it for X86CPU Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 05/10] qom/cpu: move register_vmstate to common CPUClass.realizefn Zhu Guihua
2015-03-05 18:32   ` Eduardo Habkost
2015-03-06  8:53   ` Igor Mammedov
2015-03-06  9:31     ` Chen Fan [this message]
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 06/10] qom/cpu: move apic vmstate register into x86_cpu_apic_realize Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 07/10] monitor: use cc->get_arch_id as the cpu index Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 08/10] acpi: introduce acpi_send_gpe_event() Zhu Guihua
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 09/10] cpu: add device_add foo-x86_64-cpu support Zhu Guihua
2015-03-05 18:43   ` Eduardo Habkost
2015-02-13 10:25 ` [Qemu-devel] [PATCH v4 10/10] i386/cpu: add instance finalize callback Zhu Guihua
2015-02-24  1:25 ` [Qemu-devel] [PATCH v4 00/10] cpu: add device_add foo-x86_64-cpu support Gu Zheng
2015-02-24 16:56   ` Andreas Färber
2015-02-25  9:58     ` Chen Fan
2015-02-26  9:35       ` Andreas Färber
2015-02-26 10:02         ` Chen Fan
2015-02-26  4:42     ` Bharata B Rao
2015-02-26  9:08       ` Andreas Färber
2015-03-13  6:17 ` Zhu Guihua

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=54F973FF.3060501@cn.fujitsu.com \
    --to=chen.fan.fnst@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=anshul.makkar@profitbricks.com \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tangchen@cn.fujitsu.com \
    --cc=zhugh.fnst@cn.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.