qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ulrich Obergfell <uobergfe@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: aliguori@us.ibm.com, kvm@vger.kernel.org,
	jan kiszka <jan.kiszka@siemens.com>,
	qemu-devel@nongnu.org, gcosta@redhat.com, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription
Date: Mon, 11 Apr 2011 04:24:04 -0400 (EDT)	[thread overview]
Message-ID: <1473344612.11808.1302510244411.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <4D9F2E1A.6030807@codemonkey.ws>


>>   typedef struct HPETState {
>> @@ -248,7 +253,7 @@ static int hpet_post_load(void *opaque, int
>> version_id)
>>
>>   static const VMStateDescription vmstate_hpet_timer = {
>>       .name = "hpet_timer",
>> - .version_id = 1,
>> + .version_id = 3,
>
> Why jump from 1 to 3?
> 
>>       .minimum_version_id = 1,
>>       .minimum_version_id_old = 1,
>>       .fields = (VMStateField []) {
>> @@ -258,6 +263,11 @@ static const VMStateDescription
>> vmstate_hpet_timer = {
>>           VMSTATE_UINT64(fsb, HPETTimer),
>>           VMSTATE_UINT64(period, HPETTimer),
>>           VMSTATE_UINT8(wrap_flag, HPETTimer),
>> + VMSTATE_UINT64_V(saved_period, HPETTimer, 3),
>> + VMSTATE_UINT64_V(ticks_not_accounted, HPETTimer, 3),
>> + VMSTATE_UINT32_V(irqs_to_inject, HPETTimer, 3),
>> + VMSTATE_UINT32_V(irq_rate, HPETTimer, 3),
>> + VMSTATE_UINT32_V(divisor, HPETTimer, 3),


Anthony,

I incremented the version ID of 'vmstate_hpet' from 2 to 3 to make sure
that migrations from a QEMU process that is capable of 'driftfix' to a
QEMU process that is _not_ capable of 'driftfix' will fail. I assigned
version ID 3 to 'vmstate_hpet_timer' and to the new fields in there too
to indicate that adding those fields was the reason why the version ID
of 'vmstate_hpet' was incremented to 3.

As far as the flow of execution in vmstate_load_state() is concerned, I
think it does not matter whether the version ID of 'vmstate_hpet_timer'
and the new fields in there is 2 or 3 (as long as they are consistent).
When the 'while(field->name)' loop in vmstate_load_state() gets to the
following field in 'vmstate_hpet' ...

    VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
                                vmstate_hpet_timer, HPETTimer),

... it calls itself recursively ...

    if (field->flags & VMS_STRUCT) {
        ret = vmstate_load_state(f, field->vmsd, addr, field->vmsd->version_id);

'field->vmsd->version_id' is the version ID of 'vmstate_hpet_timer' [1].
Hence 'vmstate_hpet_timer.version_id' is being checked against itself ...

    if (version_id > vmsd->version_id) {
        return -EINVAL;
    }

... and the version IDs of the new fields are also being checked against
'vmstate_hpet_timer.version_id' ...

    if ((field->field_exists &&
         field->field_exists(opaque, version_id)) ||
        (!field->field_exists &&
         field->version_id <= version_id)) {

If you want me to change the version ID of 'vmstate_hpet_timer' and the
new fields in there from 3 to 2, I can do that.


Regards,

Uli


[1] Ref.: commit fa3aad24d94a6cf894db52d83f72a399324a17bb

  reply	other threads:[~2011-04-11  8:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 15:20 [Qemu-devel] [PATCH v2 0/5] hpet 'driftfix': alleviate time drift with HPET periodic timers Ulrich Obergfell
2011-04-08 15:20 ` [Qemu-devel] [PATCH v2 1/5] hpet 'driftfix': add hooks required to detect coalesced interrupts (x86 apic only) Ulrich Obergfell
2011-04-08 15:46   ` Anthony Liguori
2011-04-08 15:51   ` [Qemu-devel] " Jan Kiszka
2011-04-08 15:20 ` [Qemu-devel] [PATCH v2 2/5] hpet 'driftfix': add driftfix property to HPETState and DeviceInfo Ulrich Obergfell
2011-04-08 15:20 ` [Qemu-devel] [PATCH v2 3/5] hpet 'driftfix': add fields to HPETTimer and VMStateDescription Ulrich Obergfell
2011-04-08 15:47   ` Anthony Liguori
2011-04-11  8:24     ` Ulrich Obergfell [this message]
2011-04-11  9:06       ` Ulrich Obergfell
2011-04-11  9:08         ` Avi Kivity
2011-04-11 13:10           ` Anthony Liguori
2011-04-11 13:39             ` Glauber Costa
2011-04-11 13:43               ` Avi Kivity
2011-04-11 13:47               ` Anthony Liguori
2011-04-11 13:57                 ` Glauber Costa
2011-04-11 13:10       ` Anthony Liguori
2011-04-08 15:20 ` [Qemu-devel] [PATCH v2 4/5] hpet 'driftfix': add code in update_irq() to detect coalesced interrupts (x86 apic only) Ulrich Obergfell
2011-04-08 15:20 ` [Qemu-devel] [PATCH v2 5/5] hpet 'driftfix': add code in hpet_timer() to compensate delayed callbacks and coalesced interrupts Ulrich Obergfell
2011-04-08 15:54   ` [Qemu-devel] " Jan Kiszka
2011-04-08 16:08     ` Glauber Costa
2011-04-08 16:12       ` Jan Kiszka

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=1473344612.11808.1302510244411.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com \
    --to=uobergfe@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=gcosta@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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).