qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 07/13] pci: convert pci_device_(save|load) interface


From: Michael Roth
Subject: [Qemu-devel] [PATCH 07/13] pci: convert pci_device_(save|load) interfaces to accept Visitors
Date: Thu, 27 Oct 2011 13:17:19 -0500

With all callers converted to Visitors, we can change the
interface to accept a Visitor directly, along with an Error** for error
propagation.

Signed-off-by: Michael Roth <address@hidden>
---
 hw/ivshmem.c    |    4 ++--
 hw/openpic.c    |    4 ++--
 hw/pci.c        |    9 +++++----
 hw/pci.h        |    6 ++++--
 hw/piix_pci.c   |    2 +-
 hw/virtio-pci.c |    4 ++--
 6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 8d0607d..264970e 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -570,7 +570,7 @@ static void ivshmem_save(QEMUFile* f, void *opaque)
 
     visit_start_struct(v, NULL, NULL, "ivshmem", 0, &err);
 
-    pci_device_save(&proxy->dev, f);
+    pci_device_save(&proxy->dev, v, &err);
 
     if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
         msix_save(&proxy->dev, v, &err);
@@ -609,7 +609,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int 
version_id)
         goto out;
     }
 
-    ret = pci_device_load(&proxy->dev, f);
+    ret = pci_device_load(&proxy->dev, v, &err);
     if (ret) {
         goto out;
     }
diff --git a/hw/openpic.c b/hw/openpic.c
index 6e8c3a3..d666bb3 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -1149,7 +1149,7 @@ static void openpic_save(QEMUFile* f, void *opaque)
         error_report("error saving openpic state: %s", error_get_pretty(err));
         error_free(err);
     }
-    pci_device_save(&opp->pci_dev, f);
+    pci_device_save(&opp->pci_dev, v, &err);
 }
 
 static int openpic_load(QEMUFile* f, void *opaque, int version_id)
@@ -1239,7 +1239,7 @@ static int openpic_load(QEMUFile* f, void *opaque, int 
version_id)
         error_report("error loading openpic state: %s", error_get_pretty(err));
         error_free(err);
     }
-    return pci_device_load(&opp->pci_dev, f);
+    return pci_device_load(&opp->pci_dev, v, &err);
 }
 
 static void openpic_irq_raise(openpic_t *opp, int n_CPU, IRQ_src_t *src)
diff --git a/hw/pci.c b/hw/pci.c
index a0ab0e0..70b1eb8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -465,22 +465,23 @@ static inline const VMStateDescription 
*pci_get_vmstate(PCIDevice *s)
     return pci_is_express(s) ? &vmstate_pcie_device : &vmstate_pci_device;
 }
 
-void pci_device_save(PCIDevice *s, QEMUFile *f)
+void pci_device_save(PCIDevice *s, Visitor *v, Error **errp)
 {
     /* Clear interrupt status bit: it is implicit
      * in irq_state which we are saving.
      * This makes us compatible with old devices
      * which never set or clear this bit. */
     s->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    vmstate_save_state(f, pci_get_vmstate(s), s);
+    vmstate_process(v, pci_get_vmstate(s), s, 0, VMS_SAVE, errp);
     /* Restore the interrupt status bit. */
     pci_update_irq_status(s);
 }
 
-int pci_device_load(PCIDevice *s, QEMUFile *f)
+int pci_device_load(PCIDevice *s, Visitor *v, Error **errp)
 {
     int ret;
-    ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
+    ret = vmstate_process(v, pci_get_vmstate(s), s, s->version_id, VMS_LOAD,
+                          errp);
     /* Restore the interrupt status bit. */
     pci_update_irq_status(s);
     return ret;
diff --git a/hw/pci.h b/hw/pci.h
index 86a81c8..a3809d3 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -11,6 +11,8 @@
 #include "isa.h"
 
 #include "pcie.h"
+#include "qapi/qapi-visit-core.h"
+#include "error.h"
 
 /* PCI bus */
 
@@ -215,8 +217,8 @@ uint32_t pci_default_read_config(PCIDevice *d,
                                  uint32_t address, int len);
 void pci_default_write_config(PCIDevice *d,
                               uint32_t address, uint32_t val, int len);
-void pci_device_save(PCIDevice *s, QEMUFile *f);
-int pci_device_load(PCIDevice *s, QEMUFile *f);
+void pci_device_save(PCIDevice *s, Visitor *v, Error **errp);
+int pci_device_load(PCIDevice *s, Visitor *v, Error **errp);
 MemoryRegion *pci_address_space(PCIDevice *dev);
 MemoryRegion *pci_address_space_io(PCIDevice *dev);
 
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 0e405f3..79506f6 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -201,7 +201,7 @@ static int i440fx_load_old(QEMUFile* f, void *opaque, int 
version_id)
 
     visit_start_struct(v, NULL, NULL, "i440fx", 0, &err);
 
-    ret = pci_device_load(&d->dev, f);
+    ret = pci_device_load(&d->dev, v, &err);
     if (ret < 0) {
         goto out;
     }
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index ca9cabc..cede802 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -106,7 +106,7 @@ static void virtio_pci_save_config(void * opaque, QEMUFile 
*f)
     Visitor *v = qemu_file_get_visitor(f);
     Error *err = NULL;
 
-    pci_device_save(&proxy->pci_dev, f);
+    pci_device_save(&proxy->pci_dev, v, &err);
     msix_save(&proxy->pci_dev, v, &err);
     if (msix_present(&proxy->pci_dev)) {
         visit_type_uint16(v, &proxy->vdev->config_vector,
@@ -144,7 +144,7 @@ static int virtio_pci_load_config(void * opaque, QEMUFile 
*f)
     Error *err = NULL;
     int ret;
 
-    ret = pci_device_load(&proxy->pci_dev, f);
+    ret = pci_device_load(&proxy->pci_dev, v, &err);
     if (ret) {
         goto out;
     }
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]