From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJUX8-0003bJ-4V for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJUX6-0000G1-Fk for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:30 -0400 Received: from mout.perfora.net ([74.208.4.194]:62328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJUX6-0000FY-9g for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:28 -0400 From: Michael Roth Date: Thu, 27 Oct 2011 13:17:14 -0500 Message-Id: <1319739445-17629-3-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1319739445-17629-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1319739445-17629-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 02/13] ivshmem: convert save/load to visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, quintela@redhat.com Signed-off-by: Michael Roth --- hw/ivshmem.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 files changed, 34 insertions(+), 10 deletions(-) diff --git a/hw/ivshmem.c b/hw/ivshmem.c index 242fbea..48e27f5 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -563,38 +563,55 @@ static void ivshmem_setup_msi(IVShmemState * s) { static void ivshmem_save(QEMUFile* f, void *opaque) { IVShmemState *proxy = opaque; + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; IVSHMEM_DPRINTF("ivshmem_save\n"); + + visit_start_struct(v, NULL, NULL, "ivshmem", 0, &err); + pci_device_save(&proxy->dev, f); if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) { msix_save(&proxy->dev, f); } else { - qemu_put_be32(f, proxy->intrstatus); - qemu_put_be32(f, proxy->intrmask); + visit_type_uint32(v, &proxy->intrstatus, "proxy.intrstatus", &err); + visit_type_uint32(v, &proxy->intrmask, "proxy.intrmask", &err); } + visit_end_struct(v, &err); + + if (err) { + error_report("error saving ivshmem state: %s", error_get_pretty(err)); + error_free(err); + } } static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) { - IVSHMEM_DPRINTF("ivshmem_load\n"); - IVShmemState *proxy = opaque; int ret, i; + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; + + IVSHMEM_DPRINTF("ivshmem_load\n"); + + visit_start_struct(v, NULL, NULL, "ivshmem", 0, &err); if (version_id > 0) { - return -EINVAL; + ret = -EINVAL; + goto out; } if (proxy->role_val == IVSHMEM_PEER) { fprintf(stderr, "ivshmem: 'peer' devices are not migratable\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } ret = pci_device_load(&proxy->dev, f); if (ret) { - return ret; + goto out; } if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) { @@ -603,11 +620,18 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) msix_vector_use(&proxy->dev, i); } } else { - proxy->intrstatus = qemu_get_be32(f); - proxy->intrmask = qemu_get_be32(f); + visit_type_uint32(v, &proxy->intrstatus, "proxy.intrstatus", &err); + visit_type_uint32(v, &proxy->intrmask, "proxy.intrmask", &err); } - return 0; + visit_end_struct(v, &err); + +out: + if (err) { + error_report("error loading ivshmem state: %s", error_get_pretty(err)); + error_free(err); + } + return ret; } static int pci_ivshmem_init(PCIDevice *dev) -- 1.7.4.1