Skip to content

Commit 6227120

Browse files
committed
hw/isa/piix4: Migrate Reset Control Register
When adding the Reset register in commit 5790b75 we forgot to migrate it. While it is possible a VM using the PIIX4 is migrated just after requesting a system shutdown, it is very unlikely. However when restoring a migrated VM, we might have the RCR bit #4 set on the stack and when the VM resume it directly shutdowns. Add a post_load() migration handler and set the default RCR value to 0 for earlier versions, assuming the VM was not going to shutdown before migration. Fixes: 5790b75 ("piix4: Add the Reset Control Register") Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20210324200334.729899-1-f4bug@amsat.org>
1 parent 50fab4c commit 6227120

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

hw/isa/piix4.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,25 @@ static void piix4_isa_reset(DeviceState *dev)
9393
pci_conf[0xae] = 0x00;
9494
}
9595

96+
static int piix4_ide_post_load(void *opaque, int version_id)
97+
{
98+
PIIX4State *s = opaque;
99+
100+
if (version_id == 2) {
101+
s->rcr = 0;
102+
}
103+
104+
return 0;
105+
}
106+
96107
static const VMStateDescription vmstate_piix4 = {
97108
.name = "PIIX4",
98-
.version_id = 2,
109+
.version_id = 3,
99110
.minimum_version_id = 2,
111+
.post_load = piix4_ide_post_load,
100112
.fields = (VMStateField[]) {
101113
VMSTATE_PCI_DEVICE(dev, PIIX4State),
114+
VMSTATE_UINT8_V(rcr, PIIX4State, 3),
102115
VMSTATE_END_OF_LIST()
103116
}
104117
};

0 commit comments

Comments
 (0)