Patchwork [06/13] i440fx: convert save/load to visitors

login
register
mail settings
Submitter Michael Roth
Date Oct. 27, 2011, 6:17 p.m.
Message ID <1319739445-17629-7-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/122205/
State New
Headers show

Comments

Michael Roth - Oct. 27, 2011, 6:17 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/piix_pci.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

Patch

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index d183443..0e405f3 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -195,20 +195,35 @@  static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id)
 {
     PCII440FXState *d = opaque;
     int ret, i;
+    uint32_t dummy;
+    Visitor *v = qemu_file_get_visitor(f);
+    Error *err = NULL;
+
+    visit_start_struct(v, NULL, NULL, "i440fx", 0, &err);
 
     ret = pci_device_load(&d->dev, f);
-    if (ret < 0)
-        return ret;
+    if (ret < 0) {
+        goto out;
+    }
     i440fx_update_memory_mappings(d);
-    qemu_get_8s(f, &d->smm_enabled);
+    visit_type_uint8(v, &d->smm_enabled, "smm_enabled", &err);
 
     if (version_id == 2) {
+        visit_start_array(v, NULL, "dummy_irqs", PIIX_NUM_PIRQS, 4, &err);
         for (i = 0; i < PIIX_NUM_PIRQS; i++) {
-            qemu_get_be32(f); /* dummy load for compatibility */
+            visit_type_uint32(v, &dummy, NULL, &err); /* dummy load for compatibility */
         }
+        visit_end_array(v, &err);
     }
 
-    return 0;
+    visit_end_struct(v, &err);
+
+out:
+    if (err) {
+        error_report("error loading i440fx state: %s", error_get_pretty(err));
+        error_free(err);
+    }
+    return ret;
 }
 
 static int i440fx_post_load(void *opaque, int version_id)