qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, quintela@redhat.com
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	[thread overview]
Message-ID: <1319739445-17629-8-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1319739445-17629-1-git-send-email-mdroth@linux.vnet.ibm.com>

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 <mdroth@linux.vnet.ibm.com>
---
 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

  parent reply	other threads:[~2011-10-27 18:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 18:17 [Qemu-devel] [PATCH 00/13] Convert slirp/ivshmem/virtio save/load to Visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 01/13] slirp: convert save/load function to visitor interface Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 02/13] ivshmem: convert save/load to visitor Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 03/13] virtio-pci: convert save/load to visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 04/13] msix: convert save/load to visitors (including interfaces) Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 05/13] openpic: convert save/load to visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 06/13] i440fx: " Michael Roth
2011-10-27 18:17 ` Michael Roth [this message]
2011-10-27 18:17 ` [Qemu-devel] [PATCH 08/13] virtio: convert common virtio " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 09/13] virtio-balloon: convert " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 10/13] virtio-blk: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 11/13] virtio-net: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 12/13] virtio-serial: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 13/13] virtio: convert virtio_save/virtio_load interfaces to accept Visitors Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319739445-17629-8-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).