Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> --- 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