[PATCH v2 for-11.2 0/2] Fix 'version' arg of VMSTATE_PTIMER

Peter Maydell posted 2 patches 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261106163657.3825938-1-peter.maydell@linaro.org
Maintainers: Alistair Francis <alistair@alistair23.me>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Chao Liu <chao.liu@processmission.com>, Jean-Christophe Dubois <jcd@tribudubois.net>
include/hw/core/ptimer.h | 2 +-
hw/dma/xlnx_csu_dma.c    | 4 ++--
hw/watchdog/k230_wdt.c   | 2 ++
hw/watchdog/wdt_imx2.c   | 1 +
4 files changed, 6 insertions(+), 3 deletions(-)
[PATCH v2 for-11.2 0/2] Fix 'version' arg of VMSTATE_PTIMER
Posted by Peter Maydell 2 weeks, 2 days ago
The VMSTATE_PTIMER macro is defined to pass a 'version' argument of 1
to VMSTATE_STRUCT_POINTER_TEST_V.  This means that the field will
only be used in migration when the vmstate struct that uses
VMSTATE_PTIMER has a version_id of at least 1.  This doesn't match
how we define other VMSTATE_FOO which don't take an explicit
version_id, which is to use a version argument of 0 (e.g. all the
common macros like VMSTATE_UINT32 are written to pass 0 to their
VMSTATE_UINT32_V counterparts, and so on). It also doesn't match
how we define VMSTATE_PTIMER_ARRAY.

The practical effect of this is that users of VMSTATE_PTIMER in
vmstate structs which explicitly or implicitly have a version_id of 0
were actually not getting their ptimers migrated.

This series:
 (1) fixes a mistake in wdt_imx2 where we bumped version_id
 but forgot to bump minimum_version_id
 (2) fixes the macro, and bumps version_id and minimum_version_id
 for the 2 vmstate structs that used VMSTATE_PTIMER and had an
 implicit or explicit version_id of 0 (vmstate_xlnx_csu_dma
 and vmstate_k230_wdt) so they cleanly fail migration from
 old to new QEMU

Changes v1->v2:
 * wdt_imx2 is no longer affected as it had a version bump for
   other reasons, but patch 1 is needed to correct an error
   in how we did it
 * patch 2 now bumps version on the affected vmstate structs

thanks
-- PMM

Peter Maydell (2):
  hw/watchdog/wdt_imx2: Set vmstate minimum_version_id to 1
  include/hw/core/ptimer.h: Fix 'version' argument of VMSTATE_PTIMER

 include/hw/core/ptimer.h | 2 +-
 hw/dma/xlnx_csu_dma.c    | 4 ++--
 hw/watchdog/k230_wdt.c   | 2 ++
 hw/watchdog/wdt_imx2.c   | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.43.0
Re: [PATCH v2 for-11.2 0/2] Fix 'version' arg of VMSTATE_PTIMER
Posted by Peter Maydell 1 week, 3 days ago
On Fri, 6 Nov 2026 at 16:36, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> The VMSTATE_PTIMER macro is defined to pass a 'version' argument of 1
> to VMSTATE_STRUCT_POINTER_TEST_V.  This means that the field will
> only be used in migration when the vmstate struct that uses
> VMSTATE_PTIMER has a version_id of at least 1.  This doesn't match
> how we define other VMSTATE_FOO which don't take an explicit
> version_id, which is to use a version argument of 0 (e.g. all the
> common macros like VMSTATE_UINT32 are written to pass 0 to their
> VMSTATE_UINT32_V counterparts, and so on). It also doesn't match
> how we define VMSTATE_PTIMER_ARRAY.
>
> The practical effect of this is that users of VMSTATE_PTIMER in
> vmstate structs which explicitly or implicitly have a version_id of 0
> were actually not getting their ptimers migrated.

As these are both reviewed I'm going to take the series via
target-arm.next.

-- PMM