diff mbox

[03/25] vmstate: make all architectures export a way to migrate cpu's

Message ID 2990903a0cc46441449790bcdb216c9b5c895507.1319550280.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Oct. 25, 2011, 2 p.m. UTC
This makes several changes:
- exports VMStateDescription vmstate_cpu non-static.
- makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
- for the architecture that had nothing, it just register the cpu as unmigratable.
- Depending on CPU_SAVE_VERSION we register old/new migration style

Signed-off-by: Juan Quintela <quintela@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Michael Walle <michael@walle.cc>
CC: Paul Brook <paul@codesourcery.com>
CC: Alexander Graf <agraf@suse.de>
CC: Aurelien Jarno <aurelien@aurel32.net>
CC: Max Filippov <jcmvbkbc@gmail.com>
---
 exec.c                  |    2 ++
 hw/hw.h                 |    2 ++
 target-alpha/machine.c  |   12 +-----------
 target-i386/machine.c   |    2 +-
 target-lm32/machine.c   |    2 +-
 target-m68k/machine.c   |   10 ++++++++++
 target-s390x/machine.c  |   14 ++++++--------
 target-sh4/machine.c    |   10 ++++++++++
 target-xtensa/machine.c |   14 ++++++--------
 9 files changed, 39 insertions(+), 29 deletions(-)

Comments

Andreas Färber Oct. 25, 2011, 3:33 p.m. UTC | #1
Am 25.10.2011 16:00, schrieb Juan Quintela:
> This makes several changes:
> - exports VMStateDescription vmstate_cpu non-static.
> - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
> - for the architecture that had nothing, it just register the cpu as unmigratable.
> - Depending on CPU_SAVE_VERSION we register old/new migration style
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

I like that move in general.

> diff --git a/target-m68k/machine.c b/target-m68k/machine.c
> index e69de29..86b6fe9 100644
> --- a/target-m68k/machine.c
> +++ b/target-m68k/machine.c
> @@ -0,0 +1,10 @@
> +
> +#include "hw/hw.h"
> +
> +/* To make this architecture migratable, we need to define cpu state
> +   here.  Other things need to be done elsewhere */
> +
> +const VMStateDescription vmstate_cpu = {
> +    .name = "cpu",
> +    .unmigratable = 1,
> +};

Here ...

> diff --git a/target-sh4/machine.c b/target-sh4/machine.c
> index e69de29..86b6fe9 100644
> --- a/target-sh4/machine.c
> +++ b/target-sh4/machine.c
> @@ -0,0 +1,10 @@
> +
> +#include "hw/hw.h"
> +
> +/* To make this architecture migratable, we need to define cpu state
> +   here.  Other things need to be done elsewhere */
> +
> +const VMStateDescription vmstate_cpu = {
> +    .name = "cpu",
> +    .unmigratable = 1,
> +};

... and here you sort-of create new files (empty before) without a
license header. The contents is trivial right now, but it would get a
case for the Wiki trying to figure out what license to put on other
people's code.

Andreas
Juan Quintela Oct. 25, 2011, 3:50 p.m. UTC | #2
Andreas Färber <afaerber@suse.de> wrote:
> Am 25.10.2011 16:00, schrieb Juan Quintela:
>> This makes several changes:
>> - exports VMStateDescription vmstate_cpu non-static.
>> - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
>> - for the architecture that had nothing, it just register the cpu as unmigratable.
>> - Depending on CPU_SAVE_VERSION we register old/new migration style
>> 
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>
> I like that move in general.
>
>> diff --git a/target-m68k/machine.c b/target-m68k/machine.c
>> index e69de29..86b6fe9 100644
>> --- a/target-m68k/machine.c
>> +++ b/target-m68k/machine.c
>> @@ -0,0 +1,10 @@
>> +
>> +#include "hw/hw.h"
>> +
>> +/* To make this architecture migratable, we need to define cpu state
>> +   here.  Other things need to be done elsewhere */
>> +
>> +const VMStateDescription vmstate_cpu = {
>> +    .name = "cpu",
>> +    .unmigratable = 1,
>> +};
>
> Here ...
>
>> diff --git a/target-sh4/machine.c b/target-sh4/machine.c
>> index e69de29..86b6fe9 100644
>> --- a/target-sh4/machine.c
>> +++ b/target-sh4/machine.c
>> @@ -0,0 +1,10 @@
>> +
>> +#include "hw/hw.h"
>> +
>> +/* To make this architecture migratable, we need to define cpu state
>> +   here.  Other things need to be done elsewhere */
>> +
>> +const VMStateDescription vmstate_cpu = {
>> +    .name = "cpu",
>> +    .unmigratable = 1,
>> +};
>
> ... and here you sort-of create new files (empty before) without a
> license header. The contents is trivial right now, but it would get a
> case for the Wiki trying to figure out what license to put on other
> people's code.

None of target-*/machine.c files have a license line.  I can put the
normal boilerplate on them, but I have just transformed them,  So .. who
should I put as copyright owner?  Puting me is (at least) a bit
presumptuous, if not just plain false O:-)

Later, Juan.
Max Filippov Oct. 25, 2011, 5:55 p.m. UTC | #3
> This makes several changes:
> - exports VMStateDescription vmstate_cpu non-static.
> - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
> - for the architecture that had nothing, it just register the cpu as unmigratable.
> - Depending on CPU_SAVE_VERSION we register old/new migration style
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

[...snip...]

> diff --git a/target-xtensa/machine.c b/target-xtensa/machine.c
> index ddeffb2..3f98330 100644
> --- a/target-xtensa/machine.c
> +++ b/target-xtensa/machine.c
> @@ -26,13 +26,11 @@
>   */
> 
>  #include "hw/hw.h"
> -#include "hw/boards.h"
> 
> -void cpu_save(QEMUFile *f, void *opaque)
> -{
> -}
> +/* To make this architecture migratable, we need to define cpu state
> +   here.  Other things need to be done elsewhere */
> 
> -int cpu_load(QEMUFile *f, void *opaque, int version_id)
> -{
> -    return 0;
> -}
> +const VMStateDescription vmstate_cpu = {
> +    .name = "cpu",
> +    .unmigratable = 1,
> +};
> 

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

Thanks.
-- Max
Richard Henderson Oct. 25, 2011, 5:58 p.m. UTC | #4
On 10/25/2011 07:00 AM, Juan Quintela wrote:
> This makes several changes:
> - exports VMStateDescription vmstate_cpu non-static.
> - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
> - for the architecture that had nothing, it just register the cpu as unmigratable.
> - Depending on CPU_SAVE_VERSION we register old/new migration style
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Michael Walle <michael@walle.cc>
> CC: Paul Brook <paul@codesourcery.com>
> CC: Alexander Graf <agraf@suse.de>
> CC: Aurelien Jarno <aurelien@aurel32.net>
> CC: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  exec.c                  |    2 ++
>  hw/hw.h                 |    2 ++
>  target-alpha/machine.c  |   12 +-----------
>  target-i386/machine.c   |    2 +-
>  target-lm32/machine.c   |    2 +-
>  target-m68k/machine.c   |   10 ++++++++++
>  target-s390x/machine.c  |   14 ++++++--------
>  target-sh4/machine.c    |   10 ++++++++++
>  target-xtensa/machine.c |   14 ++++++--------

...

> --- a/target-alpha/machine.c
> +++ b/target-alpha/machine.c
> @@ -68,20 +68,10 @@ static VMStateField vmstate_cpu_fields[] = {
>      VMSTATE_END_OF_LIST()
>  };
> 
> -static const VMStateDescription vmstate_cpu = {
> +const VMStateDescription vmstate_cpu = {
>      .name = "cpu",
>      .version_id = 1,
>      .minimum_version_id = 1,
>      .minimum_version_id_old = 1,
>      .fields = vmstate_cpu_fields,
>  };
> -
> -void cpu_save(QEMUFile *f, void *opaque)
> -{
> -    vmstate_save_state(f, &vmstate_cpu, opaque);
> -}
> -
> -int cpu_load(QEMUFile *f, void *opaque, int version_id)
> -{
> -    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
> -}

Acked-by: Richard Henderson <rth@twiddle.net>


r~
Michael Walle Oct. 25, 2011, 7:02 p.m. UTC | #5
Am Dienstag 25 Oktober 2011, 16:00:37 schrieb Juan Quintela:
> This makes several changes:
> - exports VMStateDescription vmstate_cpu non-static.
> - makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
> - for the architecture that had nothing, it just register the cpu as
> unmigratable. - Depending on CPU_SAVE_VERSION we register old/new
> migration style

[..]

> diff --git a/target-lm32/machine.c b/target-lm32/machine.c
> index 70ca52a..9014a9f 100644
> --- a/target-lm32/machine.c
> +++ b/target-lm32/machine.c
> @@ -1,7 +1,7 @@
>  #include "hw/hw.h"
>  #include "hw/boards.h"
> 
> -static const VMStateDescription vmstate_cpu = {
> +const VMStateDescription vmstate_cpu = {
>      .name = "cpu",
>      .version_id = CPU_SAVE_VERSION,
>      .minimum_version_id = 1,
> diff --git a/target-m68k/machine.c b/target-m68k/machine.c
> index e69de29..86b6fe9 100644
[..]

Acked-by: Michael Walle <michael@walle.cc>
Andreas Färber Oct. 25, 2011, 8:41 p.m. UTC | #6
Am 25.10.2011 17:50, schrieb Juan Quintela:
> Andreas Färber <afaerber@suse.de> wrote:
>>> diff --git a/target-m68k/machine.c b/target-m68k/machine.c
>>> index e69de29..86b6fe9 100644
>>> --- a/target-m68k/machine.c
>>> +++ b/target-m68k/machine.c
>>> @@ -0,0 +1,10 @@
>>> +
>>> +#include "hw/hw.h"
>>> +
>>> +/* To make this architecture migratable, we need to define cpu state
>>> +   here.  Other things need to be done elsewhere */
>>> +
>>> +const VMStateDescription vmstate_cpu = {
>>> +    .name = "cpu",
>>> +    .unmigratable = 1,
>>> +};
>>
>> Here ...
>>
>>> diff --git a/target-sh4/machine.c b/target-sh4/machine.c
>>> index e69de29..86b6fe9 100644
>>> --- a/target-sh4/machine.c
>>> +++ b/target-sh4/machine.c
>>> @@ -0,0 +1,10 @@
>>> +
>>> +#include "hw/hw.h"
>>> +
>>> +/* To make this architecture migratable, we need to define cpu state
>>> +   here.  Other things need to be done elsewhere */
>>> +
>>> +const VMStateDescription vmstate_cpu = {
>>> +    .name = "cpu",
>>> +    .unmigratable = 1,
>>> +};
>>
>> ... and here you sort-of create new files (empty before) without a
>> license header. The contents is trivial right now, but it would get a
>> case for the Wiki trying to figure out what license to put on other
>> people's code.
> 
> None of target-*/machine.c files have a license line.  I can put the
> normal boilerplate on them, but I have just transformed them,  So .. who
> should I put as copyright owner?  Puting me is (at least) a bit
> presumptuous, if not just plain false O:-)

Note my comment was specific to those that you did not really transform.

Andreas
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 165cfe8..09f3f01 100644
--- a/exec.c
+++ b/exec.c
@@ -663,6 +663,8 @@  void cpu_exec_init(CPUState *env)
 #if defined(CPU_SAVE_VERSION)
     register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
                     cpu_save, cpu_load, env);
+#else
+    vmstate_register(NULL, cpu_index, &vmstate_cpu, env);
 #endif
 #endif
 }
diff --git a/hw/hw.h b/hw/hw.h
index ed20f5a..0f0200a 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -359,6 +359,8 @@  extern const VMStateInfo vmstate_info_ptimer;
 extern const VMStateInfo vmstate_info_buffer;
 extern const VMStateInfo vmstate_info_unused_buffer;

+extern const VMStateDescription vmstate_cpu;
+
 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)

diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 76d70d9..8d32d7c 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -68,20 +68,10 @@  static VMStateField vmstate_cpu_fields[] = {
     VMSTATE_END_OF_LIST()
 };

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields = vmstate_cpu_fields,
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 25fa97d..54f5643 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -310,7 +310,7 @@  static const VMStateDescription vmstate_fpop_ip_dp = {
     }
 };

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = CPU_SAVE_VERSION,
     .minimum_version_id = 3,
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 70ca52a..9014a9f 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -1,7 +1,7 @@ 
 #include "hw/hw.h"
 #include "hw/boards.h"

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = CPU_SAVE_VERSION,
     .minimum_version_id = 1,
diff --git a/target-m68k/machine.c b/target-m68k/machine.c
index e69de29..86b6fe9 100644
--- a/target-m68k/machine.c
+++ b/target-m68k/machine.c
@@ -0,0 +1,10 @@ 
+
+#include "hw/hw.h"
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
diff --git a/target-s390x/machine.c b/target-s390x/machine.c
index 3e79be6..5a7b219 100644
--- a/target-s390x/machine.c
+++ b/target-s390x/machine.c
@@ -18,13 +18,11 @@ 
  */

 #include "hw/hw.h"
-#include "hw/boards.h"

-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */

-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return 0;
-}
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
diff --git a/target-sh4/machine.c b/target-sh4/machine.c
index e69de29..86b6fe9 100644
--- a/target-sh4/machine.c
+++ b/target-sh4/machine.c
@@ -0,0 +1,10 @@ 
+
+#include "hw/hw.h"
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
diff --git a/target-xtensa/machine.c b/target-xtensa/machine.c
index ddeffb2..3f98330 100644
--- a/target-xtensa/machine.c
+++ b/target-xtensa/machine.c
@@ -26,13 +26,11 @@ 
  */

 #include "hw/hw.h"
-#include "hw/boards.h"

-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */

-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return 0;
-}
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};