diff mbox

[RFC,02/12] migration: migrate icount fields.

Message ID 5330460F.8020807@greensocs.com
State New
Headers show

Commit Message

fred.konrad@greensocs.com March 24, 2014, 2:49 p.m. UTC
On 22/03/2014 09:57, Paolo Bonzini wrote:
> Il 21/03/2014 20:17, fred.konrad@greensocs.com ha scritto:
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> This fixes a bug where qemu_icount and qemu_icount_bias are not 
>> migrated.
>>
>> Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
>> ---
>>  cpus.c | 23 ++++++++++++++++++++++-
>>  1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/cpus.c b/cpus.c
>> index 687717f..bdbc431 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -440,12 +440,33 @@ static const VMStateDescription vmstate_timers = {
>>      }
>>  };
>>
>> +/*
>> + * This is used instead of vmstate_timers when icount is used.
>> + * cpu_ticks_offset and dummy fields are unused in icount mode so we 
>> can replace
>> + * them with icount variables.
>> + */
>> +static const VMStateDescription icount_vmstate_timers = {
>> +    .name = "timer",
>> +    .version_id = 2,
>> +    .minimum_version_id = 1,
>> +    .minimum_version_id_old = 1,
>> +    .fields      = (VMStateField[]) {
>> +        VMSTATE_INT64(qemu_icount_bias, TimersState),
>> +        VMSTATE_INT64(qemu_icount, TimersState),
>> +        VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
>> +        VMSTATE_END_OF_LIST()
>> +    }
>> +};
>> +
>>  void configure_icount(const char *option)
>>  {
>>      seqlock_init(&timers_state.vm_clock_seqlock, NULL);
>> -    vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
>> +
>>      if (!option) {
>> +        vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
>>          return;
>> +    } else {
>> +        vmstate_register(NULL, 0, &icount_vmstate_timers, 
>> &timers_state);
>>      }
>>
>>      icount_warp_timer = timer_new_ns(QEMU_CLOCK_REALTIME,
>>
>
> You can also use a subsection for this.
>
> Paolo

Hi Paolo,
Thanks for review!

Did you mean something like that:

Thanks,
Fred

Comments

Paolo Bonzini March 24, 2014, 3:42 p.m. UTC | #1
Il 24/03/2014 15:49, Frederic Konrad ha scritto:
> --- a/cpus.c
> +++ b/cpus.c
> @@ -427,6 +427,26 @@ void qemu_clock_warp(QEMUClockType type)
>      }
>  }
>
> +static bool icount_state_needed(void *opaque)
> +{
> +    return (use_icount != 0);
> +}
> +
> +/*
> + * This is a subsection for icount migration.
> + */
> +static const VMStateDescription icount_vmstate_timers = {
> +    .name = "icount",
> +    .version_id = 2,

1 here.

> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields      = (VMStateField[]) {
> +        VMSTATE_INT64(qemu_icount_bias, TimersState),
> +        VMSTATE_INT64(qemu_icount, TimersState),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>  static const VMStateDescription vmstate_timers = {
>      .name = "timer",
>      .version_id = 2,
> @@ -437,6 +457,14 @@ static const VMStateDescription vmstate_timers = {
>          VMSTATE_INT64(dummy, TimersState),
>          VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
>          VMSTATE_END_OF_LIST()
> +    },
> +    .subsections = (VMStateSubsection[]) {
> +        {
> +            .vmsd = &icount_vmstate_timers,
> +            .needed = icount_state_needed,
> +        }, {
> +            /* empty */
> +        }
>      }
>  };
>
> Thanks,
> Fred

Yes, quite exactly that part from the version_id.  If you can test it, 
this patch would be good for 2.0 too.

Paolo
fred.konrad@greensocs.com March 25, 2014, 10:25 a.m. UTC | #2
On 24/03/2014 16:42, Paolo Bonzini wrote:
> Il 24/03/2014 15:49, Frederic Konrad ha scritto:
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -427,6 +427,26 @@ void qemu_clock_warp(QEMUClockType type)
>>      }
>>  }
>>
>> +static bool icount_state_needed(void *opaque)
>> +{
>> +    return (use_icount != 0);
>> +}
>> +
>> +/*
>> + * This is a subsection for icount migration.
>> + */
>> +static const VMStateDescription icount_vmstate_timers = {
>> +    .name = "icount",
>> +    .version_id = 2,
>
> 1 here.
>
>> +    .minimum_version_id = 1,
>> +    .minimum_version_id_old = 1,
>> +    .fields      = (VMStateField[]) {
>> +        VMSTATE_INT64(qemu_icount_bias, TimersState),
>> +        VMSTATE_INT64(qemu_icount, TimersState),
>> +        VMSTATE_END_OF_LIST()
>> +    }
>> +};
>> +
>>  static const VMStateDescription vmstate_timers = {
>>      .name = "timer",
>>      .version_id = 2,
>> @@ -437,6 +457,14 @@ static const VMStateDescription vmstate_timers = {
>>          VMSTATE_INT64(dummy, TimersState),
>>          VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
>>          VMSTATE_END_OF_LIST()
>> +    },
>> +    .subsections = (VMStateSubsection[]) {
>> +        {
>> +            .vmsd = &icount_vmstate_timers,
>> +            .needed = icount_state_needed,
>> +        }, {
>> +            /* empty */
>> +        }
>>      }
>>  };
>>
>> Thanks,
>> Fred
>
> Yes, quite exactly that part from the version_id.  If you can test it, 
> this patch would be good for 2.0 too.
>
> Paolo
>
Seems there is a little issue somewhere: Unknown savevm section type 5

I'll try to debug this.

Fred
diff mbox

Patch

--- a/cpus.c
+++ b/cpus.c
@@ -427,6 +427,26 @@  void qemu_clock_warp(QEMUClockType type)
      }
  }

+static bool icount_state_needed(void *opaque)
+{
+    return (use_icount != 0);
+}
+
+/*
+ * This is a subsection for icount migration.
+ */
+static const VMStateDescription icount_vmstate_timers = {
+    .name = "icount",
+    .version_id = 2,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_INT64(qemu_icount_bias, TimersState),
+        VMSTATE_INT64(qemu_icount, TimersState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
  static const VMStateDescription vmstate_timers = {
      .name = "timer",
      .version_id = 2,
@@ -437,6 +457,14 @@  static const VMStateDescription vmstate_timers = {
          VMSTATE_INT64(dummy, TimersState),
          VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
          VMSTATE_END_OF_LIST()
+    },
+    .subsections = (VMStateSubsection[]) {
+        {
+            .vmsd = &icount_vmstate_timers,
+            .needed = icount_state_needed,
+        }, {
+            /* empty */
+        }
      }
  };