Patchwork [08/11] ide: add save/restore support for isa

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 26, 2009, 11:53 a.m.
Message ID <1251287619-20022-9-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/32138/
State Superseded
Headers show

Comments

Gerd Hoffmann - Aug. 26, 2009, 11:53 a.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/ide-isa.c |   33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/ide-isa.c b/hw/ide-isa.c
index 705c24d..279474b 100644
--- a/hw/ide-isa.c
+++ b/hw/ide-isa.c
@@ -33,13 +33,38 @@ 
 /***********************************************************/
 /* ISA IDE definitions */
 
+typedef struct ISAIDEState {
+    IDEBus *bus;
+} ISAIDEState;
+
+static void isa_ide_save(QEMUFile* f, void *opaque)
+{
+    ISAIDEState *s = opaque;
+
+    idebus_save(f, s->bus);
+    ide_save(f, &s->bus->ifs[0]);
+    ide_save(f, &s->bus->ifs[1]);
+}
+
+static int isa_ide_load(QEMUFile* f, void *opaque, int version_id)
+{
+    ISAIDEState *s = opaque;
+
+    idebus_load(f, s->bus, version_id);
+    ide_load(f, &s->bus->ifs[0], version_id);
+    ide_load(f, &s->bus->ifs[1], version_id);
+    return 0;
+}
+
 void isa_ide_init(int iobase, int iobase2, qemu_irq irq,
                   BlockDriverState *hd0, BlockDriverState *hd1)
 {
-    IDEBus *bus;
+    ISAIDEState *s;
 
-    bus = qemu_mallocz(sizeof(*bus));
+    s = qemu_mallocz(sizeof(*s));
+    s->bus = qemu_mallocz(sizeof(IDEBus));
 
-    ide_init2(bus, hd0, hd1, irq);
-    ide_init_ioport(bus, iobase, iobase2);
+    ide_init2(s->bus, hd0, hd1, irq);
+    ide_init_ioport(s->bus, iobase, iobase2);
+    register_savevm("isa-ide", 0, 3, isa_ide_save, isa_ide_load, s);
 }