@samitouri / QOSamiQemu / commits / 67a6d29c28

hw/ide: migrate the power-on defaults revert flag

SET FEATURES 0xCC asks for the next reset to revert to the power-on defaults, and 0x66 cancels that; ide_reset() restores the default CHS translation only when the flag is set. It was in no VMStateDescription, so it always arrived cleared. That was invisible while the destination had the default translation anyway. Now that the translation is migrated, the flag decides how long it stays in effect: without it, a reset after the migration reverts the geometry on the source and keeps it on the destination. Send it only alongside a translation the guest replaced. On the default geometry it reverts to what is already in effect, so such a guest need not lose its migration to an older QEMU over a subsection that changes nothing. Cc: John Snow <jsnow@redhat.com> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Fixes: 176e4961bb33 ("hw/ide/core.c: Implement ATA INITIALIZE_DEVICE_PARAMETERS command") Signed-off-by: Denis V. Lunev <den@openvz.org>

Denis V. Lunev committed Aug 4, 2026 at 18:34 UTC 67a6d29c28cc1a2628b0e1bdeac93621a9d4d9cb
1 file changed +20
hw/ide/core.c
+20
@@ -2988,6 +2988,25 @@ static const VMStateDescription vmstate_ide_drive_chs_translation = {
2988 }
2989 };
2990
2991 +static bool ide_reset_reverts_needed(void *opaque)
2992 +{
2993 + IDEState *s = opaque;
2994 +
2995 + return s->reset_reverts && ide_chs_translation_needed(opaque);
2996 +}
2997 +
2998 +/* The flag decides nothing on the default geometry, so it travels with one */
2999 +static const VMStateDescription vmstate_ide_drive_reset_reverts = {
3000 + .name = "ide_drive/reset_reverts",
3001 + .version_id = 1,
3002 + .minimum_version_id = 1,
3003 + .needed = ide_reset_reverts_needed,
3004 + .fields = (const VMStateField[]) {
3005 + VMSTATE_BOOL(reset_reverts, IDEState),
3006 + VMSTATE_END_OF_LIST()
3007 + }
3008 +};
3009 +
3010 static const VMStateDescription vmstate_ide_tray_state = {
3011 .name = "ide_drive/tray_state",
3012 .version_id = 1,
@@ -3052,6 +3071,7 @@ const VMStateDescription vmstate_ide_drive = {
3071 .subsections = (const VMStateDescription * const []) {
3072 &vmstate_ide_drive_pio_state,
3073 &vmstate_ide_drive_chs_translation,
3074 + &vmstate_ide_drive_reset_reverts,
3075 &vmstate_ide_tray_state,
3076 &vmstate_ide_atapi_gesn_state,
3077 NULL