Skip to contentSkip to conversation

timer/aspeed: fix vmstate version id

PATCH Superseded Cédric Le Goater 3 participants 8 messages Apr 23, 2018 Arm/Aspeed machine support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timer/aspeed: fix vmstate version id

commit 1d3e65aa7ac5 ("hw/timer: Add value matching support to aspeed_timer") increased the vmstate version of the timers array but doing so, it broke migration. To fix, we also need to change the vmstate version of the aspeed timer controller model.

---

To test on a 'palmetto-bmc' board, download the latest built OpenBMC flash image :

wget https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=palmetto/lastSuccessfulBuild/artifact/deploy/images/palmetto/flash-palmetto

start two instances of QEMU with :

qemu-system-arm -m 512 -M palmetto-bmc -drive file=./flash-palmetto,format=raw,if=mtd -serial mon:stdio -nographic -nodefaults

and :

qemu-system-arm -m 512 -M palmetto-bmc -drive file=./flash-palmetto,format=raw,if=mtd -serial mon:stdio -nographic -nodefaults -incoming tcp::1234

then, run migrate from the monitor:

(qemu) migrate tcp:localhost:1234

 hw/timer/aspeed_timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/timer/aspeed_timer.c +2 -2
index 50acbf530a3a..7df19bd9df91 100644
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),
Signature · 1 line
2.13.6
#1 lore raw
Quoted 33 lines · Cédric Le Goater

commit 1d3e65aa7ac5 ("hw/timer: Add value matching support to aspeed_timer") increased the vmstate version of the timers array but doing so, it broke migration. To fix, we also need to change the vmstate version of the aspeed timer controller model.

---

To test on a 'palmetto-bmc' board, download the latest built OpenBMC flash image :

wget https://openpower.xyz/job/openbmc-build/distro=ubuntu,target=palmetto/lastSuccessfulBuild/artifact/deploy/images/palmetto/flash-palmetto

start two instances of QEMU with :

qemu-system-arm -m 512 -M palmetto-bmc -drive file=./flash-palmetto,format=raw,if=mtd -serial mon:stdio -nographic -nodefaults

and :

qemu-system-arm -m 512 -M palmetto-bmc -drive file=./flash-palmetto,format=raw,if=mtd -serial mon:stdio -nographic -nodefaults -incoming tcp::1234

then, run migrate from the monitor:

(qemu) migrate tcp:localhost:1234

 hw/timer/aspeed_timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 10 lines
hw/timer/aspeed_timer.c +2 -2
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

thanks
-- PMM

#2 lore raw
Quoted 6 lines · Peter Maydell
Quoted 6 lines
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
Quoted 12 lines

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 9 lines
hw/timer/aspeed_timer.c +2 -2
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

Yes. Also.

Or bring back all the version ids to 1, as we never supported migration before.

Thanks,

C.

#3 lore raw
Quoted 20 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
Quoted 6 lines
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
Quoted 12 lines

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 9 lines
hw/timer/aspeed_timer.c +2 -2
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

Quoted 4 lines

Yes. Also.

Or bring back all the version ids to 1, as we never supported migration before.

I think it's nice to at least do the "bump version" thing, so you get a (hopefully comprehensible) error rather than just wrong data if you do try a cross version migration, so I would vote for just fixing the one thing that was wrong: the number in VMSTATE_STRUCT_ARRAY is the version to be used of the substruct, so it didn't need to be bumped in commit 1d3e65aa7a; the main version numbers for vmstate_aspeed_timer did need to be bumped because part of the main struct changed.

thanks
-- PMM

#4 lore raw
Quoted 26 lines · Peter Maydell
Quoted 20 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
Quoted 6 lines
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
Quoted 12 lines

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 9 lines
hw/timer/aspeed_timer.c +2 -2
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

Quoted 4 lines

Yes. Also.

Or bring back all the version ids to 1, as we never supported migration before.

Quoted 8 lines

I think it's nice to at least do the "bump version" thing, so you get a (hopefully comprehensible) error rather than just wrong data if you do try a cross version migration, so I would vote for just fixing the one thing that was wrong: the number in VMSTATE_STRUCT_ARRAY is the version to be used of the substruct, so it didn't need to be bumped in commit 1d3e65aa7a; the main version numbers for vmstate_aspeed_timer did need to be bumped because part of the main struct changed.

Yes. This is correct. I will resend with just that change on VMSTATE_STRUCT_ARRAY.

Thanks,

C.

#5 lore raw
In reply to Peter Maydell
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Cédric Le Goater
Quoted 18 lines · Peter Maydell
Quoted 5 lines
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 10 lines
hw/timer/aspeed_timer.c +2 -2
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

Quoted 8 lines
Quoted 4 lines

Yes. Also.

Or bring back all the version ids to 1, as we never supported migration before.

I think it's nice to at least do the "bump version" thing, so you get a (hopefully comprehensible) error rather than just wrong data if you do try a cross version migration,

On that topic, the error message was :

Missing section footer for aspeed.timerctrl

which is not very comprehensible for a version mismatch issue.

Thanks,

C.

Quoted 10 lines

so I would
vote for just fixing the one thing that was wrong: the number in VMSTATE_STRUCT_ARRAY is the version to be used of the substruct, so it didn't need to be bumped in commit 1d3e65aa7a; the main version numbers for vmstate_aspeed_timer did need to be bumped because part of the main struct changed.

thanks
-- PMM

#6 lore raw
Quoted 31 lines · * Cédric Le Goater ([email protected]) wrote:
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Cédric Le Goater
Quoted 18 lines · Peter Maydell
Quoted 5 lines
hw/timer/aspeed_timer.c +0 -0
index 50acbf530a3a..7df19bd9df91 100644

hw/timer/aspeed_timer.c static const VMStateDescription vmstate_aspeed_timer = { · line 505

Quoted 10 lines
hw/timer/aspeed_timer.c +2 -2
@@ -498,8 +498,8 @@ static const VMStateDescription vmstate_aspeed_timer = {
 
 static const VMStateDescription vmstate_aspeed_timer_state = {
     .name = "aspeed.timerctrl",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
         VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),

Wouldn't it be simpler to just fix the incorrect value in the VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState, line ?

Quoted 8 lines
Quoted 4 lines

Yes. Also.

Or bring back all the version ids to 1, as we never supported migration before.

I think it's nice to at least do the "bump version" thing, so you get a (hopefully comprehensible) error rather than just wrong data if you do try a cross version migration,

Quoted 5 lines

On that topic, the error message was :

Missing section footer for aspeed.timerctrl

which is not very comprehensible for a version mismatch issue.

Was that before your patch?

The VMSTATE fields in the structure have no metadata stored for them to be parsed with; if you send a different number of array entries to the number the destination receives you end up with a corrupt stream. Section footers are just a canary that tells you something went wrong in that devices data. It has no more information to give you a more detailed error.

Dave

Quoted 15 lines

Thanks,

C.

Quoted 10 lines

so I would
vote for just fixing the one thing that was wrong: the number in VMSTATE_STRUCT_ARRAY is the version to be used of the substruct, so it didn't need to be bumped in commit 1d3e65aa7a; the main version numbers for vmstate_aspeed_timer did need to be bumped because part of the main struct changed.

thanks
-- PMM

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#7 lore raw
Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

I think it's nice to at least do the "bump version" thing, so you get a (hopefully comprehensible) error rather than just wrong data if you do try a cross version migration,

On that topic, the error message was :

Missing section footer for aspeed.timerctrl

which is not very comprehensible for a version mismatch issue.

Was that before your patch?

yes.

Quoted 6 lines

The VMSTATE fields in the structure have no metadata stored for them to be parsed with; if you send a different number of array entries to the number the destination receives you end up with a corrupt stream. Section footers are just a canary that tells you something went wrong in that devices data. It has no more information to give you a more detailed error.

OK. Thanks for the explanation.

C.