Commit 67a6d29c28 for qemu.org

commit 67a6d29c28cc1a2628b0e1bdeac93621a9d4d9cb
Author: Denis V. Lunev <den@openvz.org>
Date:   Tue Aug 4 18:34:44 2026 +0200

    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>

diff --git a/hw/ide/core.c b/hw/ide/core.c
index b074325afa..5a5f072630 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2988,6 +2988,25 @@ static const VMStateDescription vmstate_ide_drive_chs_translation = {
     }
 };

+static bool ide_reset_reverts_needed(void *opaque)
+{
+    IDEState *s = opaque;
+
+    return s->reset_reverts && ide_chs_translation_needed(opaque);
+}
+
+/* The flag decides nothing on the default geometry, so it travels with one */
+static const VMStateDescription vmstate_ide_drive_reset_reverts = {
+    .name = "ide_drive/reset_reverts",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = ide_reset_reverts_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_BOOL(reset_reverts, IDEState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_ide_tray_state = {
     .name = "ide_drive/tray_state",
     .version_id = 1,
@@ -3052,6 +3071,7 @@ const VMStateDescription vmstate_ide_drive = {
     .subsections = (const VMStateDescription * const []) {
         &vmstate_ide_drive_pio_state,
         &vmstate_ide_drive_chs_translation,
+        &vmstate_ide_drive_reset_reverts,
         &vmstate_ide_tray_state,
         &vmstate_ide_atapi_gesn_state,
         NULL