Received: from eggs.gnu.org ([140.186.70.92]:53138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJUXK-0004JH-Ro for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJUXJ-0000NU-9O for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:42 -0400 Received: from mout.perfora.net ([74.208.4.195]:54900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJUXI-0000NP-UM for qemu-devel@nongnu.org; Thu, 27 Oct 2011 14:18:41 -0400 From: Michael Roth Date: Thu, 27 Oct 2011 13:17:15 -0500 Message-Id: <1319739445-17629-4-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 03/13] virtio-pci: convert save/load to visitors 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/virtio-pci.c | 63 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 52 insertions(+), 11 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index ca5923c..9092c02 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -103,53 +103,94 @@ static void virtio_pci_notify(void *opaque, uint16_t vector) static void virtio_pci_save_config(void * opaque, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; + pci_device_save(&proxy->pci_dev, f); msix_save(&proxy->pci_dev, f); - if (msix_present(&proxy->pci_dev)) - qemu_put_be16(f, proxy->vdev->config_vector); + if (msix_present(&proxy->pci_dev)) { + visit_type_uint16(v, &proxy->vdev->config_vector, + "proxy.vdev.config_vector", &err); + } + if (err) { + error_report("error saving virtio-pci config: %s", + error_get_pretty(err)); + error_free(err); + } } static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; - if (msix_present(&proxy->pci_dev)) - qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n)); + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; + uint16_t vector; + + if (msix_present(&proxy->pci_dev)) { + vector = virtio_queue_vector(proxy->vdev, n); + visit_type_uint16(v, &vector, "vector", &err); + } + if (err) { + error_report("error saving virtio-pci queue: %s", + error_get_pretty(err)); + error_free(err); + } } static int virtio_pci_load_config(void * opaque, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; int ret; + ret = pci_device_load(&proxy->pci_dev, f); if (ret) { - return ret; + goto out; } msix_load(&proxy->pci_dev, f); if (msix_present(&proxy->pci_dev)) { - qemu_get_be16s(f, &proxy->vdev->config_vector); + visit_type_uint16(v, &proxy->vdev->config_vector, + "proxy.vdev.config_vector", &err); } else { proxy->vdev->config_vector = VIRTIO_NO_VECTOR; } if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { - return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); + ret = msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); } - return 0; +out: + if (err) { + error_report("error loading virtio-pci config: %s", + error_get_pretty(err)); + error_free(err); + } + return ret; } static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; + Visitor *v = qemu_file_get_visitor(f); + Error *err = NULL; uint16_t vector; + int ret = 0; if (msix_present(&proxy->pci_dev)) { - qemu_get_be16s(f, &vector); + visit_type_uint16(v, &vector, "vector", &err); } else { vector = VIRTIO_NO_VECTOR; } virtio_queue_set_vector(proxy->vdev, n, vector); if (vector != VIRTIO_NO_VECTOR) { - return msix_vector_use(&proxy->pci_dev, vector); + ret = msix_vector_use(&proxy->pci_dev, vector); + goto out; } - return 0; +out: + if (err) { + error_report("error loading virtio-pci config: %s", + error_get_pretty(err)); + error_free(err); + } + return ret; } static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, -- 1.7.4.1