hw/ide: restore the power-on device state before loading
Loading a snapshot reuses the IDEState of the machine it is loaded into: load_snapshot() resets the machine and then feeds the stream into the existing devices. The reset does not help, as ide_reset() restores the logical CHS translation only when the guest asked for power-on defaults to be reverted with SET FEATURES 0xCC. A guest that replaced the translation with INITIALIZE DEVICE PARAMETERS therefore keeps it across the load of a snapshot taken before it did, while the restored guest expects the geometry of that moment. Every CHS access then lands on a sector other than the one asked for, with no error reported. s->reset_reverts survives a load the same way. Add a pre_load restoring the defaults, which docs/devel/migration/main.rst recommends for state a stream need not carry, and which the following subsections rely on. The RESET_TYPE_SNAPSHOT_LOAD marking that reset would be another way to recognise the case, but no IDE controller can see it while they all use device_class_set_legacy_reset(). 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>