include/hw/boards: cope with dev/rc versions in deprecation checks

When VERSION is set to a development snapshot (micro >= 50), or a release
candidate (micro >= 90) we have an off-by-1 in determining deprecation
and deletion thresholds for versioned machine types. In such cases we need
to use the next major/minor version in threshold checks.

This adapts the deprecation macros to do "next version" prediction when
seeing a dev/rc version number.

This ensures users of release candidates get an accurate view of machines
that will be deprecated/deleted in the final release.

This requires hardcoding our current release policy of 3 releases per
year, with a major bump at the start of each year, and that dev/rc
versions have micro >= 50.

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2025-02-25 19:36:23 +00:00
parent 3dfa5a5c71
commit f59ee04406

View file

@ -650,11 +650,42 @@ struct MachineState {
" years old are subject to deletion after " \
stringify(MACHINE_VER_DELETION_MAJOR) " years"
#define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \
#define _MACHINE_VER_IS_CURRENT_EXPIRED(cutoff, major, minor) \
(((QEMU_VERSION_MAJOR - major) > cutoff) || \
(((QEMU_VERSION_MAJOR - major) == cutoff) && \
(QEMU_VERSION_MINOR - minor) >= 0))
#define _MACHINE_VER_IS_NEXT_MINOR_EXPIRED(cutoff, major, minor) \
(((QEMU_VERSION_MAJOR - major) > cutoff) || \
(((QEMU_VERSION_MAJOR - major) == cutoff) && \
((QEMU_VERSION_MINOR + 1) - minor) >= 0))
#define _MACHINE_VER_IS_NEXT_MAJOR_EXPIRED(cutoff, major, minor) \
((((QEMU_VERSION_MAJOR + 1) - major) > cutoff) || \
((((QEMU_VERSION_MAJOR + 1) - major) == cutoff) && \
(0 - minor) >= 0))
/*
* - The first check applies to formal releases
* - The second check applies to dev snapshots / release candidates
* where the next major version is the same.
* e.g. 9.0.50, 9.1.50, 9.0.90, 9.1.90
* - The third check applies to dev snapshots / release candidates
* where the next major version will change.
* e.g. 9.2.50, 9.2.90
*
* NB: this assumes we do 3 minor releases per year, before bumping major,
* and dev snapshots / release candidates are numbered with micro >= 50
* If this ever changes the logic below will need modifying....
*/
#define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \
((QEMU_VERSION_MICRO < 50 && \
_MACHINE_VER_IS_CURRENT_EXPIRED(cutoff, major, minor)) || \
(QEMU_VERSION_MICRO >= 50 && QEMU_VERSION_MINOR < 2 && \
_MACHINE_VER_IS_NEXT_MINOR_EXPIRED(cutoff, major, minor)) || \
(QEMU_VERSION_MICRO >= 50 && QEMU_VERSION_MINOR == 2 && \
_MACHINE_VER_IS_NEXT_MAJOR_EXPIRED(cutoff, major, minor)))
#define _MACHINE_VER_IS_EXPIRED2(cutoff, major, minor) \
_MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor)
#define _MACHINE_VER_IS_EXPIRED3(cutoff, major, minor, micro) \