qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, tangchen@cn.fujitsu.com,
	guz.fnst@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com,
	chen.fan.fnst@cn.fujitsu.com, anshul.makkar@profitbricks.com,
	afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v3 2/7] qom/cpu: move register_vmstate to common CPUClass.realizefn
Date: Thu, 29 Jan 2015 15:04:44 +0100	[thread overview]
Message-ID: <20150129150444.6653ea36@nial.brq.redhat.com> (raw)
In-Reply-To: <dbc9e588cdf51138e2c005eb58d122e879fd3716.1421214155.git.zhugh.fnst@cn.fujitsu.com>

On Wed, 14 Jan 2015 15:27:25 +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            | 32 +++++++++++++++++++-------------
>  include/qom/cpu.h |  2 ++
>  qom/cpu.c         |  2 ++
>  3 files changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index 081818e..c9ffda6 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -513,10 +513,28 @@ 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);
that probable would be source migration problems:
because cc->get_arch_id(cpu) depending on topology might
be not sequential, for example: sockets=4,core=3
that would create sparse APIC numbering.

as result migration from old qemu to one with this change
would be rejected due to vmsd id mismatch mismatch.

we need a better way to handle cross version migration
between old/new scheme.

> +
> +    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)
that ifdef block affects only sparc/mips/cris and builds target specific code
while you are trying to call it from target independent qom/cpu.c

I'd suggest leave it where it was or better move into respective
targets realize_fns

> +    register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
> +                    cpu_save, cpu_load, cpu->env_ptr);
> +    assert(cc->vmsd == NULL);
> +    assert(qdev_get_vmsd(DEVICE(cpu)) == NULL);
> +#endif
> +    if (cc->vmsd != NULL) {
> +        vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
> +    }
> +}
> +
>  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 +557,6 @@ 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)
> -    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);
> -    }
And in general do CONFIG_USER_ONLY targets actually need/use
migration code?

>  }
>  
>  #if defined(TARGET_HAS_ICE)
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 2098f1c..936afcd 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -562,6 +562,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 9c68fa4..a639822 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -302,6 +302,8 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
>  {
>      CPUState *cpu = CPU(dev);
>  
> +    cpu_vmstate_register(cpu);
> +
>      if (dev->hotplugged) {
>          cpu_synchronize_post_init(cpu);
>          cpu_resume(cpu);

  reply	other threads:[~2015-01-29 14:05 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14  7:27 [Qemu-devel] [PATCH v3 0/7] cpu: add device_add foo-x86_64-cpu support Zhu Guihua
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 1/7] cpu: introduce CpuTopoInfo structure for argument simplification Zhu Guihua
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 2/7] qom/cpu: move register_vmstate to common CPUClass.realizefn Zhu Guihua
2015-01-29 14:04   ` Igor Mammedov [this message]
2015-02-09  8:30     ` Chen Fan
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 3/7] qom/cpu: move apic vmstate register into x86_cpu_apic_realize Zhu Guihua
2015-01-29 14:07   ` Igor Mammedov
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 4/7] monitor: use cc->get_arch_id as the cpu index Zhu Guihua
2015-01-29 14:12   ` Igor Mammedov
2015-01-29 14:21     ` Peter Krempa
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 5/7] acpi:cpu hotplug: set pcmachine as icc bus' hotplug handler Zhu Guihua
2015-01-29 14:18   ` Igor Mammedov
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 6/7] cpu: add device_add foo-x86_64-cpu support Zhu Guihua
2015-01-29 14:46   ` Igor Mammedov
2015-01-29 16:01     ` Eduardo Habkost
2015-01-29 16:39       ` Andreas Färber
2015-02-06  5:27         ` Chen Fan
2015-01-14  7:27 ` [Qemu-devel] [PATCH v3 7/7] i386/cpu: add instance finalize callback Zhu Guihua
2015-01-29 15:25   ` Igor Mammedov
2015-02-05 11:49 ` [Qemu-devel] [PATCH v3 0/7] cpu: add device_add foo-x86_64-cpu support Stefan Hajnoczi
2015-02-05 15:25   ` Eric Blake
2015-02-05 19:29     ` Junio C Hamano
2015-02-05 19:57       ` Jeff King
2015-02-05 20:17         ` Junio C Hamano
2015-02-06 19:33           ` Jeff King
     [not found]             ` <CAMuHMdWbHMPEwkYvzKzzc6L0T8ufk62DGS2sZ1w1BthL1kAZWA@mail.gmail.com>
2015-02-16 22:34               ` [Qemu-devel] [PATCH] send-email: ask confirmation if given encoding name is very short Junio C Hamano
2015-02-18 18:58                 ` Jeff King

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=20150129150444.6653ea36@nial.brq.redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=anshul.makkar@profitbricks.com \
    --cc=chen.fan.fnst@cn.fujitsu.com \
    --cc=guz.fnst@cn.fujitsu.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 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).